WordPress.org

Ready to get started?Download WordPress

Forums

Query Multiple Taxonomies
list view does not update correctly (9 posts)

  1. krakra
    Member
    Posted 1 year ago #

    I am using two instances of the widget one is list the other checkboxes. I want to select items in any of the views and have the change reflect in the other view. But found out that they operate completely differently.

    When I have all the checkboxes selected correctly the list view doesn't show them as selected and gives me an option (+) to add them to the selection. Also it doesn't show count at all. Count is 0 even that there are related posts. When I do click them they are added to the url using a different method.

    First they are added with a + to the end of the url (I need ,) and second the url changes to ?category_name=cat1+cat2+cat3

    For comparison the checkboxes add the items what appears to be category IDs with the following url ?qmt%5Bcategory%5D%5B%5D=13&qmt%5Bcategory%5D%5B%5D=18&qmt%5Bcategory%5D%5B%5D=11

    WHYYYYYYYYYYYYYYYYYYYYY???? Where can I change this behavior in the code? Any help will be greatly appreciated, the plugin is great but I can't understand the reason for this decision.

    What I need seems to be extremely simple. I am fine with any solution that gives me the following functionality

    If using the list view example I want to click on cat4(currently not selected) and get this
    ?category_name=cat1,cat2,cat3,cat4
    Click on cat1(currently selected) and get this
    ?category_name=cat2,cat3,cat4
    The change should be reflected in both the list and checkbox view of the plugin. They should show the corrected categories selected.

    Thank You!

    http://wordpress.org/extend/plugins/query-multiple-taxonomies/

  2. krakra
    Member
    Posted 1 year ago #

    Ok, it seems to be working as expected after making the following changes

    Walkers.php line 41 and 84 change + to ,
    Core.php line 246 chahge + to ,

    Can somebody please give additional information on why this was set differently before as it would be too obvious to be a bug.

    Any other changes that I missed?

    Thanks

  3. Drew Jaynes (DrewAPicture)
    Volunteer Moderator
    Plugin Author

    Posted 1 year ago #

    Can somebody please give additional information on why this was set differently before as it would be too obvious to be a bug.

    + vs , are the equivalent of AND vs OR. It sounds like you're wanting to filter by any in many categories which is not what this plugin was intended for. It was intended to "drill down" results based on A & B, and X & Y, not A or B, and X or Y.

  4. krakra
    Member
    Posted 1 year ago #

    Ok this makes sense. Actually I need all in many which I think is what this plugin is intended for. However the checkboxes and list view are using different operators. Checkboxes use OR and lists use AND. This actually seems to be a bug. With the modification that I made I basically forced both of the views to use OR. I need to use AND, so thanks for pointing this out!

    However If you add two widgets on the page one with checkboxes and one with lists based on the same criteria say Categories you will see that they don't reflect the Category selection the same way. They should use the same operator and both show the correct category selection!

    I think other people have made the observation already as well, can somebody else confirm this to be a bug?

  5. scribu
    Member
    Plugin Author

    Posted 1 year ago #

    Yes, I have noticed several people getting confused by the fact that 'checkbox' mode uses a different operator than 'list' and 'radio' modes.

  6. Jason
    Member
    Posted 1 year ago #

    ^^ I noticed this as well, and have been using a customized version for a long time. Mustache is also kinda wonkey, the brackets don't work as expected.

    You can see it in action here:
    http://fortsmith.city.cx/

    It's used to filter posts out by location AND industry. (Dropdown AND List)

    Works good, even with Ajax.

  7. krakra
    Member
    Posted 1 year ago #

    Thanks to everybody for the input. I changed

    walkers.php line 171 from , to +
    core.php line 242 from , to +
    Util.php line 103 from , to +

    and the checkboxes seem to be using AND now.

    Jason: The site looks great! What other changes did you make and how did you go about implementing Ajax?

    scribu: I think if you can implement AND/OR selection on per widget basis it will make the plugin really powerful. For example you add the widget in the backend and it has an option which taxonomy to use(currently implemented) but also which operator(AND/OR). This way you can add multiple widgets on different taxonomies and have a really powerful and flexible search!

    Also, I noticed the listbox shows the counts not per taxonomy but per result basis. So if I have 3 posts in a category, and I update the selection to show 2 posts from a different category, the category count will read 2 next to the selected categories but 0 next to all other categories in the list.

  8. scribu
    Member
    Plugin Author

    Posted 1 year ago #

    scribu: I think if you can implement AND/OR selection on per widget basis it will make the plugin really powerful.

    I agree, but I handed over plugin development/maintenance to DrewAPicture, so it's up to him.

    Of course, if you can open a pull request over at https://github.com/scribu/wp-query-multiple-taxonomies I'm sure it would help speed things along. ;)

  9. krakra
    Member
    Posted 1 year ago #

    One last thing that seems to be an issue with the checkboxes. In core.php line 15 the operator used is IN. This somehow was working as an AND until I tested it some more and now it seems to be some sort of a hybrid where the checkboxes and lists are both showing the correct selection however the checkboxes still act as an OR. After changing core.php line 15 to AND the checkboxes do act as an AND.

    However if I select a parent category it will show no results even that there are posts both set for it and its children categories. In the case of the IN operator selecting the parent category alone was showing the correct result, however it was not acting as an AND operator.

    Strangely enough the lists still work as expected!

    Any ideas how to fix this?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic