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:
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.
The topic ‘List Categories In Order Of Hierarchy’ is closed to new replies.
Subscribe to get early access to new themes, discounts and brief updates about what's new with StudioPress!