• Resolved musicmann

    (@musicmann)


    Is it possible to pre-select the category in the dropdown?

    Specifically, I have a site in which each post/CPT is assigned to one category. If someone is looking at a post in in a particular category, it is most likely that any search will also be in that same category.

    Ideally, I’d like to look at the current look at the currently displayed post, to determine the pre-selected category.

    With my limited PHP skills, I can determine the category of the currently displayed post, but I don’t immediately see where I could add it to the form created by the plugin.

    https://wordpress.org/plugins/search-filter/

Viewing 1 replies (of 1 total)
  • Plugin Author Ross Morsali

    (@designsandcode)

    Hi musicmann

    Unfortunately there isn’t a way within the plugin, although you could trick it into selecting it..

    Basically, the plugin will get data from the URL to determine what search has been performed and set up the form defaults.

    So, if you are on an article or post, and you would like the category preselected then you would need to add a parameter to the URL to show the category.

    eg:

    www.yoursite.com/324/article-title/?category_name=yourcategory

    This will then preselect this category in the search form.

    Hopefully this will get you started too – it looks like this filter – http://codex.wordpress.org/Plugin_API/Filter_Reference/post_link
    will allow you to modify the links to your posts on your site so that you can add the category name to all of them easily

    🙂

Viewing 1 replies (of 1 total)

The topic ‘Possible to Pre-Select Category’ is closed to new replies.