Title: custom posts hierarchy
Last modified: August 22, 2016

---

# custom posts hierarchy

 *  Resolved [stug2013](https://wordpress.org/support/users/stug2013/)
 * (@stug2013)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-posts-hierarchy/)
 * Hi, I am wanting to create a simple two tier custom post type hierarchy. I have
   looked at the advanced options and can see that you can set the Hierarchical 
   value to true but how do you designate the parent?
    Thanks
 * [https://wordpress.org/plugins/custom-post-type-ui/](https://wordpress.org/plugins/custom-post-type-ui/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-posts-hierarchy/#post-5320137)
 * You designate the parent/child relationships when actually creating the posts
   in the post type.
 *  Thread Starter [stug2013](https://wordpress.org/support/users/stug2013/)
 * (@stug2013)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-posts-hierarchy/#post-5320235)
 * Sorry Michael, I know I’m being thick but can you run that by me a different 
   way. I see now where you mean in the attributes box of the post but I think I
   am going about creating the custom post types in the wrong way because I don’t
   get what I want as an option. Perhaps if I explain what I want to do you would
   be kind enough to point me in the right direction. I think I am getting in a 
   mess as to what should be a custom post type and a taxonomy.
    Within my website
   which has normal blog posts on it I am creating what I am calling a magazine 
   with regular posts from 5 different people, like a column in a newspaper. Each
   column has a name, lets say one in ‘chocolate recipes’. what I am trying to achieve
   is to have these as columns collected within the magazine custom post type and
   then the posts collected under each relevant column. So then the address bar 
   would look something like: [http://www.mysite/magazine/chocolate-recipes/chocolate-chilli.html](http://www.mysite/magazine/chocolate-recipes/chocolate-chilli.html)
 * thanks for your help
    Stu
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-posts-hierarchy/#post-5320256)
 * Hi Stu,
 * Thank you for the more information, it does actually help.
 * It sounds like “Magazine” should be the post type, and then you could create 
   a “columns” taxonomy and “chocolate recipes” would be one of the terms in that
   taxonomy.
 * If I recall right, that should facilitate urls that equal out to [http://www.mysite/magazine/chocolate-recipes/chocolate-chilli/](http://www.mysite/magazine/chocolate-recipes/chocolate-chilli/).
   However, I can’t recall exactly how easy it is to get both the post type slug
   and the taxonomy terms in the permalink at the same time. That one may take a
   little bit more work.
 * Hope that helps clear up some confusion.
 *  Thread Starter [stug2013](https://wordpress.org/support/users/stug2013/)
 * (@stug2013)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-posts-hierarchy/#post-5320257)
 * Thanks Michael, I will give it a go.
 *  [FredW](https://wordpress.org/support/users/fredw/)
 * (@fredw)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-posts-hierarchy/#post-5320292)
 * Hi Michael,
 * Not sure whether this is tackled somewhere but can’t find the solution after 
   loooong hours of searching.
 * I used the plugin Custom Post Types UI to create a custom post type. Now a new
   archive page has been created. Then I created posts and child posts that are 
   assigned to their parent post.
 * Now, on the archive page, both the parent posts and the child posts are displayed
   in a list (this is a list of the posts that I created). Is there a way to display
   only the parent posts and not the child posts?
 * Many thanks for your reply:)
 * Fred
 *  Plugin Contributor [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * (@tw2113)
 * The BenchPresser
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-posts-hierarchy/#post-5320294)
 * This should work, tested myself. Make sure to replace “ENTER POST TYPE SLUG HERE”
   with your actual post type slug you want this for. Add the snippet and amend 
   it in your theme’s functions.php file.
 *     ```
       function fredw_cptui_hide_child_posts( $query ) {
       	if ( !$query->is_main_query() || is_admin() ) {
       		return;
       	}
   
       	if ( is_post_type_archive( 'ENTER POST TYPE SLUG HERE' ) ) {
       		$query->set( 'post_parent', '0' );
       	}
       }
       add_action( 'pre_get_posts', 'fredw_cptui_hide_child_posts' );
       ```
   

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘custom posts hierarchy’ is closed to new replies.

 * ![](https://ps.w.org/custom-post-type-ui/assets/icon-256x256.png?rev=2744389)
 * [Custom Post Type UI](https://wordpress.org/plugins/custom-post-type-ui/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/custom-post-type-ui/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/custom-post-type-ui/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-post-type-ui/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-post-type-ui/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-post-type-ui/reviews/)

## Tags

 * [custom post](https://wordpress.org/support/topic-tag/custom-post/)

 * 6 replies
 * 3 participants
 * Last reply from: [Michael Beckwith](https://wordpress.org/support/users/tw2113/)
 * Last activity: [11 years, 8 months ago](https://wordpress.org/support/topic/custom-posts-hierarchy/#post-5320294)
 * Status: resolved