Site logo

Archived topic

Show Child Categories first

10 replies · Started by Andrew on February 20, 2022

Viewing posts 1–11 of 11

I've done a search of the forum but I didn't see what I was looking for, sorry if this is a repost.

When using the dynamic text element list of terms to display categories I'd like to reverse the hierarchy order so that child categories are listed first all the way back to the parent.

This is how it was working before I installed some plugins (iTheme security and Yoast SEO). I suspected Yoast was the culprit but disabling it did not help. Either way I'd like to keep these plugins enabled.

Is there a way with a hook to reorder the categories?

Thanks,
Andrew

Done! Thanks for taking a look :)

Sorry did you add your site link to the private info field? But I don't see it...

Hi Ying. I think I know how I messed up. I replied with ONLY something in the private field and maybe those don't go through. I am adding something to the private field on this post, hopefully you get it.

Thanks!

Some additional information that might help. I also updated to the latest version of the GeneratePress template today and I'm wondering if that caused the change.

I restored a copy of a backup from a couple of days ago before I changed anything, and I'm serving that at a different URL. This way you can compare how it is now to how it was behaving before. Before I was running version 3.1.1 of the theme.

Link in the private section. Thanks!

Hi Andrew,

Do you have some filter applies to the old site? Or atleast, do both sites have the exact same plugins active?

The latest update doesn't have any code changes related to the post meta.

3.1.1 here - https://github.com/tomusborne/generatepress/blob/df0190c5f0ac485cb78cb7c2e01365758c4c9d30/inc/structure/post-meta.php#L234-L249

and the latest - https://github.com/tomusborne/generatepress/blob/master/inc/structure/post-meta.php#L234-L249

You can see that they have the exact same code.

That said, a filter or a plugin must be changing how they are sorted.

Thanks! I'll start with the restore and reapply my changes one-by-one to see where the behavior is introduced. One more question in the private field and then I'll mark this resolved.

Do you mean why the child category shows in the post meta as well?

As far as I remember that's the normal behavior, are you expecting do NOT show the child category?
https://www.screencast.com/t/XoTcDnJyoD

Let me know!

Ok - I figured out what changed it. I switched out my SEO plugin (installed YOAST and removed RankMath). It turns out RankMath was what was putting the primary category first in the term list.

I still don't know why I get a subcategory in the category list if I go to site.com/category/parent_category (which should have no child category), but I got around that by making a hero for the parent category pages that uses Title instead of category.

I'm all set now. Thanks for the support.

Glad you found it out :)

This archived topic is closed to new replies.