Articles of hierarchical

Modifying Custom Post Type after registration (will it affect content?)

I have a CPT (defined in functions.php) that I have set to as non-hierarchical. A lot of content has already been uploaded into the database. If I change the definition to ‘hierarchical’ => true, will the change affect any of the posts in that CPT?

How to only show posts on last child category

By default WordPress will list posts on each category in its hierarchy. Example: Parent /- child /– grandchild When viewing the “Parent” category you will see a list of posts from child, grandchild and parent – even if the post is just ticked in “Grandchild”. My question is: How do I only show posts when […]

Category tree is flattened inside admin upon saving

Is there a way to avoid WordPress “flattening” the category tree when a child category is selected? This applies to both custom taxonomies and WP’s built in “category” taxonomy. To explain further, say I have the following category tree: Parent Child Grandchild Another parent Another child Another child A third parent If I then select […]

how to get the categories for a single post in a hierarchical way

The question is simple. Imagine that I have a post named ‘Single Post’ which is inside the category ‘sub-cat’ which is a child of ‘parent-cat’ which is a child of ‘super-cat’. What I need to do is to display all the related categories within the post page in the following order: super-cat > parent-cat > […]

How to include parent terms in hierarchical taxonomy URLs?

For all custom taxonomies, the URLs look like: /base/slug/. I need a solution to for my hierarchical taxonomies to have: /base/parentslug/childslug/. Anybody knows how to redirect and or to have the same functionality like categories?

How to enable hierarchical permalinks for hierarchical taxonomies

If you have a category called “term” and a subcategory called “subterm”, your can access subterm posts at /cat/subcat. But this doesn’t work out of the box with custom taxonomies. They are accessible at /taxonomy/subterm, but not /taxonomy/term/subterm. They’ve gone over this in the WordPress Trac (, and it kind of looks like they have […]

Custom Post Type with two hierarchical Custom Taxonomies: strategy to generate best permalink structure

this is my situation: I have a Custom Post Type named struttura (like accommodation): function custom_post_struttura() { $labels = array( ‘name’ => _x( ‘Strutture’, ‘post type general name’ ), ‘singular_name’ => _x( ‘Struttura’, ‘post type singular name’ ), ‘add_new’ => _x( ‘Aggiungi nuova’, ‘book’ ), ‘add_new_item’ => __( ‘Aggiungi nuova Struttura’ ), ‘edit_item’ => __( […]

How can I get an <h2> tag to wrap each ancestor that gets outputted in this condition?

I found this snippet in a different thread and it mostly does what I need, but I’m having trouble wrapping the individual pages this outputs with tags. All I can seem to add is a line break. I don’t have a lot of experience with php so unfortunately I wasn’t able to customize it to […]

Hierarchical Custom Posts – Highlighting Current Post in Sub-Menu

I have created a hierarchical custom post type called events and have used wp_list_pages to list the sub-posts for each event post (See below). This navigation works great, but I cannot figure out how to highlight the menu items based on the post being viewed. I normally use .current_menu_item, but this class is not generated […]

Custom Posts Hierarchy? (State/City/Restaurant)

Question: What is the best way to create a hierarchy structure (also called parent/child relationships) between custom post types? For example, we currently have 3 post types: States, Cities, and Restaurants. Each Restaurant will be in a city, and each city will of course be in a state. So for example, Joe’s Crab Shack would […]