- This topic has 3 replies, 2 voices, and was last updated 9 years, 4 months ago by .
- The topic ‘List Categories In Order Of Hierarchy’ is closed to new replies.
These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.
I was wondering if anyone had any insight on how to modify post meta to list categories (or custom terms to be more specific) in order of their parent/child relationships - as opposed to a simple alphabetical list.
A pet blog with a post listed under the following categories: "Dogs," "Small Breeds," & "Chihuahua." Dog is the main category. Small Breeds is a child category under Dogs, and Chihuahua is a third level category under Small Breeds.
The post meta for this would read "Filed Under: Chihuahua, Dogs, Small Breeds." (alphabetical)
How would I go about listing them based on parent/child relationships? ("Filed Under: Dogs, Small Breeds, Chihuahua")
Thanks in advance!
Hey, I'm not sure what your level of WordPress customization is?
When you call the list of categories (http://codex.wordpress.org/Function_Reference/wp_get_post_categories) you should use the args array to specify your "orderby" as "parent" (http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters).
To change the post meta, use this function, but skip the shortcodes so you can use the function above:
We create mobile-first, PageSpeed-optimized, pixel-perfect custom themes! https://www.oncecoupled.com
ugh. Let's just say my level of customization is such that I should have known better. 😉
I seem to have a developed a bad habit of looking so hard at Genesis and it's handy hooks and snippets that I completely overlook basic WordPress functions I've been using for years.
© 2023 WPEngine, Inc.