WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
[resolved] multiple categories stripped (7 posts)

  1. Doodlebee
    Member
    Posted 2 years ago #

    I hate to report this as not working, but it's true. I'm using Relevanssi with custom code to use checkboxes to select multiple categories to search in. Typically, you can add a hiden input field in your search function that says <input type="hidden" name="cat" value="<?php echo $catlist; ?>" /> and the default WordPress search will search only in the categories chosen, as supplied by he $catlist variable. However, I've found that something in Revlanssi strips that default functionality, and only searches the very first category in the list - and ignores all others.

    I don't mind that this plugin has a "premium" (i.e. "paid for") service that will give you advanced functionality, but I *do* mind that this plugin strips the default functionality and forces you to buy the premium version to repair it. That just doesn't seem right. I'm not implying that the author of the plugin is trying to rip anyone off (truly, I am not - this is really a great plugin) - I'm just hoping this is just some bug that hasn't been noticed yet and can be repaired, because *default* functionality shouldn't be messed with, except to improve upon it.

  2. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

    What's the default behaviour of WordPress search? A comma-separated list of category id's? Or is it something else?

    It doesn't work, but it's not actually Relevanssi's fault. Relevanssi can handle a list of comma-separated category values, but WordPress doesn't pass one. If you set cat=1,2,3, WordPress will only pass cat=1 to Relevanssi. I haven't figured out a way to pass several categories in that argument, but looks like there isn't one.

    And don't worry - this doesn't work in Premium, either. There's every meaning to offer all WordPress search functionality, but since I've never found anything that would document how the WordPress search actually works, it's a process of fixing things that people tell me to fix. This is one of those.

  3. Doodlebee
    Member
    Posted 2 years ago #

    What's the default behaviour of WordPress search? A comma-separated list of category id's?

    Yes. When I remove your plugin, the comma-separated values do, indeed do exactly what they are supposed to. When I reactivate the plugin, it ignores all the IDs save the first one.

    >>WordPress search actually works, it's a process of fixing things that people tell me to fix. This is one of those.<<

    Okay, well I'll change my vote form "doesn't work" to "works (because truly, it *is* a terrific plugin) and this is obviously some kind of bug. I've been working on it myself, though - so if I figure anything out, I'll pass the info to you.

    Thanks so much!

  4. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

    If WordPress insists on stripping the extra categories from the query, the best solution is probably to add a new query variable (say, 'cats'), which can handle several categories.

  5. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

    This was very easy to fix. I just added a query variable 'cats' and replace 'cat' with it if it's present. Nothing else is needed, and the category stuff works like a charm.

    Also, it has worked from Relevanssi settings all the time, but then it of course applies on every search.

    Anyway, this'll be fixed today in Premium 1.4.3 and in Free 2.8.2 which is also coming soon, hopefully later this week - still have to take a look around and see what else needs to and can be done with it.

  6. Doodlebee
    Member
    Posted 2 years ago #

    Sweet! Thank you! That's awesome :)

  7. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

    Ok, so it took me a little longer than what I promised, but I just committed 2.8.2 to the repository. It'll fix this AND the does the same for post types as well, just use post_types.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags