Forums Forums Search & Filter Pro "Order terms by Count" does not include count of child terms

Tagged: , ,

Viewing 4 posts - 1 through 4 (of 4 total)
  • Anonymous
    #95327

    Hi there.

    I have created a search form that filters by a custom taxonomy using checkboxes. I have ticked ‘Display Count’, ‘Hierarchical’ and ‘Include Children in Parents’. I have then gone into the advanced settings and set ‘Order terms by’ to ‘Count’.

    The count displays correctly, including posts in child terms, but the ordering of the terms seems to ignore the child terms. For example:

    ‘Fruits (12)’ has 12 entries
    ‘Vegetables(6)’ has 6 entries
    ‘Meats(15)’ has 5 entries and 2 child terms, ‘Red (5)’ and ‘White (5)’

    They appear in the order you see above, but including its children, ‘Meats’ has more entries than the other terms so it should appear at the top of the list, not the bottom. The count in brackets is correct but the order is not.

    Looking forward to hearing from you.

    Thank you.

    Trevor
    #95454

    In the posts for the meats ones, are both the terms Meats AND Red (for example) checked in the taxonomy meta box, or just Red and not Meats?

    Anonymous
    #95500

    You mean for the individual posts? In this example, all posts in the ‘Red’ term are marked as ‘Red’ but not as ‘Meat’. I’m sure adding them as ‘Meat’ as well would fix the ordering but as the displayed counts seem to include children, I’d have thought it should be possible to include the children in the ordering too. Forcing the user to add all parent terms whenever they add a child term is not really an option, partly because I can’t guarantee all users will follow this rule and partly because it wouldn’t always make sense.

    Here’s an example:

    If I’m running a shop website and I label my products with taxonomies, it’s logical to expect that if an item is tagged as ‘red meat’, it should also be tagged as ‘meat’.

    However, if I want to tag customers with their interests, someone (let’s say Bob) who is interested in ‘red meat’ may not be at all interested in ‘meat’ in general. Bob’s interest is specific so he would need to be tagged just with ‘red meat’ and not ‘meat’. If I then filtered my customers by ‘meat’, with the ‘Include Children in Parents’ flag switched on, I’d expect to see Bob included in the count in brackets (which currently is working) but I’d also expect ‘meat’ to be in the correct order when the terms are ordered by count.

    Essentially, when terms are ordered by count, this should be impossible:

    > Fruits (12)
    > Vegetables(6)
    > Meats(15)
    > Red meat (5)
    > White meat (5)

    ‘Meats’ should be at the top, even though only 5 posts are directly tagged as ‘meat’, because when you include posts tagged as its children, the count is 15 (as it says correctly in the label).

    Trevor
    #95504

    Right now, by default the plugin only sorts by the count excluding the children. I wonder if it is possible to modify the query using our Edit Query Arguments filter. It should be, if it can be done in general in WordPress.

    You might want to do a search in this forum for sf_edit_query_args orderby to see if there any code snippets. For example, I found this thread. Not the same question, but it does show another user has used this filter.

Viewing 4 posts - 1 through 4 (of 4 total)