¿Desea permitir a los usuarios filtrar entradas y páginas en su sitio WordPress? Recientemente, uno de nuestros usuarios nos preguntó cómo añadir filtros a su sitio WordPress permitiendo a los usuarios filtrar entradas por categoría, etiquetas, tipos de contenido, etc. En este artículo, le mostraremos cómo permitir a los usuarios filtrar entradas y páginas en WordPress.
¿Por qué permitir a los usuarios filtrar entradas y páginas en WordPress?
Por defecto, WordPress viene con categorías y etiquetas como una forma de ordenar el contenido en debates y para que sus usuarios puedan encontrarlo fácilmente.
Sin embargo, los usuarios solo pueden ver una categoría, etiqueta o página de archivo a la vez y solo mostrará un tipo de contenido.
¿Y si quisieras que los usuarios pudieran filtrar el contenido en más de una categoría o etiqueta? ¿Y acerca de permitir a los usuarios ver entradas, páginas y tipos de contenido personalizados al mismo tiempo?
Este tipo de filtrado puede ser especialmente útil cuando tienes mucho contenido y quieres que los usuarios lo filtren según sus preferencias.
Dicho esto, echemos un vistazo a cómo permitir fácilmente a los usuarios filtrar entradas y páginas en WordPress.
Video Tutorial
Si no te gusta el vídeo o necesitas más instrucciones, sigue leyendo.
Permitir a los usuarios filtrar fácilmente entradas y páginas
Lo primero que tienes que hacer es instalar y activar el plugin Search & Filter. Para más detalles, consulte nuestra guía paso a paso sobre cómo instalar un plugin de WordPress.
Una vez activado, el plugin añadirá un nuevo elemento / artículo de menú llamado Search & Filter a su barra de administrador de WordPress. Al hacer clic en él, accederá a la página de uso del plugin con documentación detallada sobre cómo utilizarlo.
Search & Filter plugin viene con un shortcode que acepta diferentes parámetros para mostrar las opciones de filtrado. Puedes usar este shortcode en una entrada, página o dentro de un widget de texto.
[searchandfilter fields="search,category,post_tag"]
También puede utilizar el shortcode como una etiqueta de plantilla en los archivos de su tema de WordPress como este:
<?php echo do_shortcode('[searchandfilter fields="search,category,post_tag"]'); ?>
Esto mostrará las opciones de filtrado con los campos de búsqueda, categoría y etiquetas.
Por defecto el plugin acepta campos de búsqueda, taxonomía, post_type y post_date.
Veamos otro ejemplo. Esta vez incluiremos los campos categoría, etiquetas, tipo de entradas y fecha.
Usted tendrá que utilizar el shortcode como este:
[searchandfilter fields="search,category,post_tag,post_types,post_date"]
Así es como quedaría:
Ahora, en lugar de utilizar un campo de selección desplegable, también puede utilizar casillas de verificación y añadir etiquetas para cada campo. Para ello, tendrá que añadir dos parámetros más para el shortcode.
Si utiliza una página separada para mostrar las entradas de su blog, puede añadir este shortcode a la página.
[searchandfilter headings="Select categories:" types="checkbox" fields="category"]
Si utiliza varios campos, tipos y encabezados, debe asegurarse de que los elementos están en el mismo pedido / orden para cada parámetro.
Veamos otro ejemplo. Esta vez estamos añadiendo campos de categoría, etiquetas y tipo de entrada con diferentes encabezados y tipos de campo de formulario.
[searchandfilter headings="Post type, Category, Tag" types="checkbox, select, select" fields="post_types,category,post_tag"]
Así es como se vería en su sitio:
Por favor, consulte la página de documentación del plugin para más formas de utilizar el shortcode.
También puede utilizar estos shortcodes dentro de un widget de texto. Si el shortcode no funciona en tu widget de texto, consulta nuestra guía sobre cómo usar shortcodes en los widgets de la barra lateral de WordPress.
Esperamos que este artículo te haya ayudado a aprender cómo permitir a los usuarios filtrar entradas y páginas en WordPress. Puede que también quieras ver estos consejos prácticos para atraer tráfico a tu sitio WordPress.
Si te ha gustado este artículo, suscríbete a nuestro canal de YouTube para ver tutoriales en vídeo sobre WordPress. También puedes encontrarnos en Twitter y Facebook.
Syed Balkhi says
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
Himanshu Gautam says
hi
I am using this plugin
is there any option to select a category without hitting the submit button?
Marwan Nour says
Hello there,
I am trying to implement Search & Filter in a website that’s both in Arabic and in English. The English version of the Search & Filter is working well however in the Arabic Version, after hitting search, I am redirected to the English Version of the search page with the results in English. Can anyone help me with that issue please? Thank you
WPBeginner Support says
You would want to reach out to the plugin’s support to see if this could be a conflict with the plugin and the translation plugin you’re using.
Administrador
Tom Ale says
Hi, I am using WordPress with Gantry.
I installed this plugin and used a shortcode. It appears where it suppose to be. When clicking the button to filter content, nothing happens. Did anyone face this problem? Help, please.
Sébastien Albert says
Hi,
Search & Filter looks great. But could you tell me if it can do that :
I would have a filter on tags but only on one category which I could define…
Thanks a lot
Sebastien
Soumik Sadman Anwar says
How can I create filter options in a single post?
For example, If I am interested in writing a post “Necessary Tools to Build A Website” and want to include filter options like Purpose Based Tools (like SEO, Design etc.) and the Price option (Free or Paid), how do I do it?
Pavel says
Great plugin, but have some limitations and bugs.
1. No Reset button.
2. When I uncheck all checkboxes and press Submit, it transfers to the front page.
Maybe there’s an option Show all?
Wolney Mamede says
First of all, thanks for the post.
I would like to know if it is possible to filter the search from the group of fields, created from the “Advanced Custom Fields – v. 4.4.12” plugin.
Also by default, the search would be restricted to a custom post type from the “Custom Post Type UI – v. 1.5.8” plugin.
Sultan Haider says
Hi, I had created employ database on tablepress and i want to filter in front end employ according to year wise for example if i select 2013 this shows only those employ which join in 2013.
i have perform lot of research but i cant find free pluggin according to my need.
please help me for suggestion.
thanks
Christine says
Thanks a lot for the comprehensive article. Do you know if it is also possible to have only certain tags in the dropdowns?
Pawan says
Great Job. just one last question. Instead of searching the post, is it possible to search category using the search string? I would like to show all the possible post in search page and then the category if it matches the search string (partially or fully).
Maz says
Hi,
Great as always.
I just wonder would the use of this plugin be recommended on a site with many posts? Will it not lead to slower load time?
Thanks
Matus says
Could you please give us a little bit deeper look to your behind the scenes? (in Blueprint post you write only what you’re using – you can also write if you want, how to properly set up plugins, themes…)
For example tutorial on 10 tips and trick to masterize or customize Genesis Framework would be really really helpful.
Patxi says
Hi WPBeginner!
In relation to the filters of new taxonomies, a question of initiation, how I can visualize in the post a new taxonomy for a second type of labels that later I can filter with this plugin?
It would be an interesting topic.
Thanks for you post!
Omer Causey says
Your suggestions for allowing users to filter posts are welcome, but the explanation of how and where to insert the required shortcode is beyond this beginner’s understanding.
WPBeginner Support says
Hi Omer,
You can add the shortcode in a post or page. If you want to display the filter site-wide then you will need to edit your WordPress theme files and use the template tag instead.
Administrador