{"id":1861,"date":"2024-08-03T08:48:22","date_gmt":"2024-08-03T06:48:22","guid":{"rendered":"https:\/\/blog.sutilweb.eu\/?page_id=1861"},"modified":"2024-08-03T08:48:24","modified_gmt":"2024-08-03T06:48:24","slug":"16-busquedas","status":"publish","type":"page","link":"https:\/\/sutilweb.eu\/index.php\/cmss-frameworks\/wordpress-2\/wordpress-avanzado\/16-busquedas\/","title":{"rendered":"16. B\u00fasquedas"},"content":{"rendered":"\n<p>Para poder hacer una b\u00fasqueda en <strong>WP<\/strong> necesitamos tener un formulario de b\u00fasqueda que el mismo <strong>WP<\/strong> nos va a facilitar. Vamos a poner en el <strong>sidebar secundario<\/strong> un formulario de b\u00fasqueda.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Tenemos que crear un archivo <em>search.php<\/em> para las b\u00fasquedas, que a\u00fan no hemos creado. La variable <strong><em>s<\/em><\/strong> (<strong><em>?s<\/em><\/strong>) es la que utiliza <strong>WP<\/strong> para las b\u00fasquedas.<\/p>\n\n\n\n<p>El algoritmo de b\u00fasqueda se basa en el porcentaje de b\u00fasquedas:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Primero en el t\u00edtulo.<\/li>\n\n\n\n<li>Luego en el contenido como tal en las publicaciones.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">get_search_query()<\/h2>\n\n\n\n<p>Es la funci\u00f3n que utilizamos en nuestro <em>search.php<\/em> para ofrecer las respuestas a las preguntas de nuestros usuarios mediante el formulario de b\u00fasqueda. Con <strong>WP<\/strong> nos evitamos estar haciendo <strong>queries<\/strong> a la <strong>DDBB,<\/strong> ya nos ofrece todo. Si somos frontends, <strong>WP<\/strong> se encarga de toda la l\u00f3gica.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Para poder hacer una b\u00fasqueda en WP necesitamos tener un formulario de b\u00fasqueda que el mismo WP nos va a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1809,"menu_order":15,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"class_list":["post-1861","page","type-page","status-publish","hentry"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Sutil Web","author_link":"https:\/\/sutilweb.eu\/index.php\/author\/sutilweb\/"},"uagb_comment_info":0,"uagb_excerpt":"Para poder hacer una b\u00fasqueda en WP necesitamos tener un formulario de b\u00fasqueda que el mismo WP nos va a [&hellip;]","_links":{"self":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/1861","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/comments?post=1861"}],"version-history":[{"count":2,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/1861\/revisions"}],"predecessor-version":[{"id":1863,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/1861\/revisions\/1863"}],"up":[{"embeddable":true,"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/pages\/1809"}],"wp:attachment":[{"href":"https:\/\/sutilweb.eu\/index.php\/wp-json\/wp\/v2\/media?parent=1861"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}