WordPress.org

Ready to get started?Download WordPress

Forums

WP Ultimate Search
[resolved] Limit search to taxonomies (5 posts)

  1. farraday1
    Member
    Posted 1 year ago #

    Hi,
    glad your plugin is back in the wp repo. It´s an awesome plugin and I purchased the pro version.

    I am using the plugin as a custom search for taxonomies, so it doesn´t replace the wp-search. The filter function works great for my taxonomies so far. Still, I am wondering how I can limit the search to my taxonomies whenever a user types in a search word directly? This will find posts aswell at the moment. As for my special custom post type template they don´t fit into that design at all and I need to exclude them somehow.

    Is there any way to achieve that without editing template files?

    Thanks in advance

    http://wordpress.org/extend/plugins/wp-ultimate-search/

  2. Bryce Corkins
    Member
    Plugin Contributor

    Posted 1 year ago #

    Thanks again for your support!

    I'm afraid I'm not 100% clear on your question, but maybe I can explain better how queries are generated.

    The way the search algorithm deals with multiple parameters is that it runs an "OR" operation on each taxonomy or meta field given. You can see this on our demo site at http://ultimatesearch.mindsharelabs.com. So, for example, a search for (Category: Change Log) (Category: Parent Category I) will return all posts from both categories. When multiple taxonomies are used, the search runs an "AND" operation... for example, (Category: Change Log) (Category: Parent Category I) (Tag: Cool) will return all posts from both categories, but only those which have the "Cool" tag.

    So, if you're allowing a user to filter by taxonomy, but the user enters plain text as well, for example (Category: Change Log) (Category: Parent Category I) (Text: Lorem), the search results will return all posts from both Change Log and Parent Category I, but only those posts which have the text "Lorem". So it sounds like it's doing what you're asking... only returning results from the taxonomies specified. However, if a user were just to enter "Lorem", then it would return all results from all taxonomies.

    It's in our roadmap for the near future to allow global taxonomy limits, set within the wpus preferences. For example, you could limit all search results to the "Change Log" category, even when a user doesn't specify a category and only enters a text search. Or, you could exclude certain taxonomies, post types, or meta field from the results, globally.

    In the meantime, if this is what you're looking to accomplish, you could easily modify the results template to do a simple check and exclude results of a certain category or post type. For more info on creating a custom results template, see the FAQ at http://mindsharelabs.com.

    Hope this clears things up. Please let me know if you need any more help.

  3. farraday1
    Member
    Posted 1 year ago #

    Thank you so much - you were 100% clear on my question.

    "However, if a user were just to enter "Lorem", then it would return all results from all taxonomies."

    That´s what I want / need to avoid. I have created a custom template for my needs already which works perfectly except for the mentioned issue.

    Good to hear that I could solve that within the template file. Do you have any hint or snippet on that?

  4. Bryce Corkins
    Member
    Plugin Contributor

    Posted 1 year ago #

    Gotcha. Yeah, that's a planned feature, but for now.. add a simple "if" check right after setup_postdata that checks if the result is in your desired taxonomy, and ignores it if not. For a start, see: http://codex.wordpress.org/Function_Reference/wp_get_post_terms

  5. farraday1
    Member
    Posted 1 year ago #

    Thanks a lot!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic