Support » Plugin: Beautiful taxonomy filters » Is it possible to add a free-text search box?

  • The filtering is great, but I’d love a keyword search as well.

    So there would be a text input in the filter panel called Search, and the redirect rules would add this with an S parameter, like:

    /cpt/taxslug/value/taxslug/value/s/value/page/1

    There may need to be some tweaking so that WordPress doesn’t automatically flip to using the search.php template instead of the archive-cpt.php template.

    Is this possible with actions/filters, or would it need custom coding?

    Is it something you’ve considered adding?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter zigpress

    (@zigpress)

    Follow-up:

    I managed to do various things in my theme to implement this using actions and filters that exist in the plugin, and the only modification I had to make to the plugin was in the “is_btf_filtered” function in api.php:

    At the start of the function I added:

    if (apply_filters(‘beautiful_filters_is_btf_filtered’, false) === true) return true;

    This lets me force the plugin to consider that the filter is active, so that the clear link is shown.

    It would be fantastic if you could add this filter to the plugin.

    Plugin Author Jonathandejong

    (@jonathandejong)

    Hi!

    Actually it’s entirely possible to add a search input as it is and I’m pretty sure I’ve answered that in older topics as well 🙂

    I’ve implemented that myself in many projects. The reason it isnt part of the plugin is because that would extend the plugin beyond a taxonomy filter. So in order to keep it as lean as possible for people who just want what the plugins name says I’ve decided for now to not include such a feature.

    You can add a search input using plugins hooks and if you just use a different name than s you can have the input submit along with the regular filters. Then it’s just a matter of hooking into the pre_get_posts and finding if that parameter was sent and modify the global $wp_query accordingly (namely, add the value as the s parameter). That’ll make the search work in tandem with the filtered taxonomies too.

    Sorry I can’t give you a fullblown tutorial for it. I’d like to write a post about it but my free time is very limited nowadays :/

    Thread Starter zigpress

    (@zigpress)

    Thanks very much for the reply, I appreciate it.

    I’ve actually managed to get it working, using pretty much exactly the technique you describe.

    Would you be able to implement the filter I detailed in my follow-up question? That would be the icing on the cake.

    @zigpress Hello, care to share the code how you enable this Search bar thing? I would like to do it too and I don’t understand the explanation that you guys put in here.

    Thread Starter zigpress

    (@zigpress)

    There are too many separate pieces of code to share on here.

    However, I will be forking this plugin as soon as I get time. My fork will be called ZP Taxonomy Filters and will contain all the extra bits discussed above, and it will be available at zigpress.com/plugins when ready.

    You’ll need to give me a few weeks though as I’m very busy.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Is it possible to add a free-text search box?’ is closed to new replies.