• Resolved petercarlill

    (@petercarlill)


    I seem to be having the same problem as detailed here:

    https://www.ads-software.com/support/topic/wp_list_categories-partially-broken/

    I’m running the plugin alongside the function below to create the dropdown menus for Fashion and Home on the site https://discovervintage.co.uk/, the Home one is working and displaying a hierarchal structure, the Fashion one is broken and is not displaying the hierarchy, just a flat list.

    They are both using the same code, but different values in ‘child_of’.

    Disabling the Custom Taxonomy Order plugin fixes the issue, but also resets the order to default, which isn’t our preferred.

    wp_list_categories( array(
    'taxonomy' => 'product_cat',
            'orderby'            => 'name',
            'show_count'         => false,
            'use_desc_for_title' => false,
            'child_of'           => 23,
    'title_li' => "",
    'echo' => 0
        ) );

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Marcel Pol

    (@mpol)

    Strange, apparently the Fashion list does get sorted, but the Home list does not get sorted. Looking at the code, I would expect both to get sorted ??

    Could you install the plugin Query Monitor and check what happens with both database queries? Apparently one sorts on t.term_order and one on t.name.

    Part of the problem is that this plugin is mostly a one-size-fits-all, it is not easy to change the orderby for different queries.

    And maybe a strange idea, but what if you use this filter on line 194 to also ignore product_cat on sorting here? It was not designed for that, it was to workaround something else. It might just fit your need. Though I don’t have any idea if you use the filter get_terms anywhere else (directly, or indirectly like here).
    https://plugins.trac.www.ads-software.com/browser/custom-taxonomy-order-ne/trunk/customtaxorder.php#L192

    And maybe ( I have no real idea), when orderby=name is set specifically in the args for a query function, maybe this plugin should not overwrite that. But then again, ignoring the settings in this plugin might cause a lot of people to experience changed behaviour.

    Thread Starter petercarlill

    (@petercarlill)

    Thanks, that’s odd.

    I’ve now removed 'orderby' => 'name' from both functions as this wasn’t the desired effect I wanted anyway – I wanted them to be overwritten by the plugin and use the custom order I’d set.

    When using Query Monitor, the Fashion function (child of 23) throws up:

    SELECT t.*, tt.*
    FROM wpdl_terms AS t
    INNER JOIN wpdl_term_taxonomy AS tt
    ON t.term_id = tt.term_id
    WHERE tt.taxonomy IN ('product_cat')
    ORDER BY t.name ASC

    But also throws up one for ‘update_meta_cache’ as below.

    SELECT term_id, meta_key, meta_value
    FROM wpdl_termmeta
    WHERE term_id IN (86,121,35,361,81,93,62,117,56,66,228,96,233,245,229,54,323,330,38,41,53,226,326,46,79,224,52,73,72,329,77,231,120,122,225,67,49,340,97,43,123,60,55,78,92,61,327,90,118,48,281,282,42,129,116,47,341,36,44,232,50,125,126,127,128,39,234,227,325,70,222,57,223,91,85,94,68,83,124,69,80,88,342,71,45,82,65,59,63,74,84,89,15,328,346,331,37,230,324)
    ORDER BY meta_id ASC

    The home function (child of 22) throws up only:

    SELECT t.*, tt.*
    FROM wpdl_terms AS t
    INNER JOIN wpdl_term_taxonomy AS tt
    ON t.term_id = tt.term_id
    WHERE tt.taxonomy IN ('product_cat')
    ORDER BY t.name ASC

    For reference in the Fashion list, Ladies, Gents and Children should be the top level categories, and all the others should be showing under their respective parent as in the Home example.

    • This reply was modified 3 years, 2 months ago by petercarlill.
    Plugin Author Marcel Pol

    (@mpol)

    Hi Peter,
    Can i thank you for reporting this issue? These are long standing issues that I am simply too afraid to touch ??

    I think I fixed it, but I prefer to get some feedback from you before I release it to all users.
    Can you try the current version in git from:
    https://gitlab.com/toomanybicycles/custom-taxonomy-order-ne

    If it works for you correctly, let me know.

    Thread Starter petercarlill

    (@petercarlill)

    It worked!

    Thanks for that, and very happy to help try to solve the problem ??

    For some reason I did have to go back in and set my preferred custom order for the Home subcategories, but the fashion subcategories were still in the desired order.

    This version with the plugin from GIT is live on the site now at https://discovervintage.co.uk/

    Plugin Author Marcel Pol

    (@mpol)

    Thank you for the feedback, great that it works.

    And yes, I forgot to mention the affected terms needed to be saved again. So apparently the bug was there.
    I will see if I can release it tomorrow.

    Have a good week.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Issue with child_of in wp_list_categories’ is closed to new replies.