• Resolved kusachiy

    (@kusachiy)


    Hello,

    On archive.php I use $list_cat = wp_list_categories ('title_li=&show_count=1&depth=1&echo=0&show_option_none=no&child_of=' . $cat_id); to build links to subcategories of current category. The problem is that while plugin is activated, the code above doesn’t work properly – on one category it returns not he list od subcategories, bur the list of sub-subcategories.

    I mean, I have the structure like this:

    Cat-1-1
    – Cat-2-1
    — Cat-3-1
    — Cat-3-2
    -Cat-2-2
    -Cat 2-3
    Cat-1-2

    In Cat-1-1, I should get list of Cat-2-1, Cat-2-2 and Cat-2-3. But I get subcats of Cat-2-1 – Cat-3-1 and Cat-3-2. Other top-level cat – Cat-1-2 returns its subcats as it should do. Id I deactivate plugin, Cat-1-1 returns its subcats properly.

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

    (@mpol)

    Hi,
    I tried to reproduce it, but it works for me. I can imagine there is a bug here, so let’s try to dig into it ??

    Which theme are you using? I tested on twenty sixteen.
    And where does $cat_id come from?
    Any other plugin that you use that does something to categories?
    And which setting do you have chosen for the categories, custom order, alphabetical order?

    Thread Starter kusachiy

    (@kusachiy)

    I use old theme Arthemia, but it totally modified by me, the discussed part is added by me.
    $cat_id comes from:

    $category = get_category( get_query_var( 'cat' ) );
    $cat_id = $category->cat_ID;

    I use Enhanced Categories, but its deactivation doesn’t help.
    I also used old, dicontinued plugin Category Order (https://wpguy.com/plugins/category-order), but it is deactivated, I’m trying to replace it with your plugin. But may be its changes to databese of taxonomies affect to work of your plugin…

    The option of sorting in your plugin is “Custom order”.

    I discovered that wp_list_categories without “child_of=” option works good, it displays section of “problem” category right. So I wrote a workaround:

    if ($cat_id == 15 )
    { $list_cat = wp_list_categories ('title_li=&show_count=1&depth=2&echo=0&show_option_none=no&exclude=1,13,35,49,26,601,2185,2194'); }

    For category with id=15 (“problem” category) call wp_list_categories and exclude all top-level cats except one category wich subcategoris I need. As “depth” is “2”, it returns $list_cat with links to Cat-1-1 and – what I need – Cat-2-1, Cat-2-2 and Cat-2-3. After that I just remove link to Cat-1-1 from $list_cat.

    Plugin Author Marcel Pol

    (@mpol)

    Hello,
    I am sorry, but I cannot explain what is happening, I don’t understand it myself ??

    The category-order plugin stored the soprt order in wp_options. This plugin adds a db field to the wp_terms table with the name term_order. The old plugin should not interfere with this one.

    As far as I understand, this plugin does not interfere with get_terms in a way that should affect this. It is mostly doing the sorting after it is fetched from the database.
    The only thing I can imagine is that the sort_order gets changed in the query and that is affecting something in what is being fetched from the database.
    I need to think a bit more on if and how that can affect things.

    It could also be that term_order in the filters is decided by a float in the form of ancestor_order,term_order, where all children are sorted similarly, and there is a walker running later that is showing them all as similar.

    It is confusing me a bit ??

    Plugin Author Marcel Pol

    (@mpol)

    Good thing you found a workaround though.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘wp_list_categories partially broken’ is closed to new replies.