Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Not quite sure why it's even available because I cannot find any documentation on how to make a custom post type hierarchical other than in the optional parameter 'hierarchical' => true....Can someone please give me a basic example of a hierarchical custom post type and the child custom post type?

For example, if I wanted to create a custom post type of "Crayon Box" and a child custom post type of "Crayon", how would one do this? Again, I am more than willing to read through some documentation but there is absolutely nothing that I can find on this in the Wordpress Codex.

UPDATE: I did read in one post where someone used post_parent but I am also unable to find documentation on this parameter...

share|improve this question
add comment

2 Answers

One custom post type cannot be the child of another. hierarchical means: Each post can have children of the same post type, like pages.

If you need relationships between different post types use the Posts 2 Posts plugin.
Another option would be a custom hierarchical taxonomy for two post types. You could use it to assign the first post type to the parent terms and the second to the child terms of that taxonomy. That's probably as messy as it sounds. :)

share|improve this answer
    
Yes, it does sound messy. Not quite sure why this functionality is not there. It seems to me that this would be a widely used architecture...and everyone seems to reply with the same thing..."use the Posts 2 Posts plugin". Not griping about your reply because at least you explained that it can't happen, but just upset that it actually can't happen :) do you know if WP plans on adding this as functionality any time soon? –  ClockwiseQ Oct 2 '12 at 1:37
    
See the discussion in core.trac.wordpress.org/ticket/14513. –  toscho Oct 2 '12 at 11:08
add comment

What functionality do you need? It might be best to use custom taxonomies as toscho mentioned. That way, you can query in the same sort of manner I envisage you wanting by having a child post type.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.