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.

I have a lot of custom type items in my new WP project, and for navigation reasons, I want to make the parent to some of them a Wordpress page. The problem is that apparently, Wordpress does not let you establish parent-child relationships between items with different post type.

Is there anyway to override this? I am using Wordpress 3.1

share|improve this question
    
Do you only need to have them hierarchically linked in the navigation menu or also in their URLs? Because the latter is much more complicated. –  Jan Fabry May 26 '11 at 15:49
    
Dupe of wordpress.stackexchange.com/questions/13308/… –  gregmac Jan 13 '12 at 4:09

2 Answers 2

There are way's to get around it to create this kind of grouping or relationship:

  1. "manually" - set the post_parent field to the parent ID (by manually i mean code something that will do that for you when you publish a CPT).
  2. Using a shared custom taxonomy to create a grouping of posts and you will have the ability to filter / query posts based on that taxonomy term.
  3. using a post meta field (custom field) on your custom post type that will hold the parent page id and once again have the ability to to filter / query posts based on that custom field
  4. using a plugin like Posts 2 Posts which uses a db table to create a many to many relation between posts and adds some cool query features.

depends on your needs but i think at least one of these should do the job.

share|improve this answer
    
Thank you for such a well thought reply. I tried number 1 by setting post_parent to my desired parent id via the database, but it doesnt work, wordpress starts doing weird stuff with that post, and it does not display at all when you open it. Any ideas? The rest of the solutions would not work for our case, because the navigation relies on the parent-child relationships, not on custom taxonomies or meta fields... –  0al0 May 26 '11 at 16:03
1  
@0al0 take a look at my answer to a similar question wordpress.stackexchange.com/questions/13308/… –  Bainternet May 26 '11 at 16:16

You just need to make sure the custom post type it's hierarchical. So within your register_post_type function, make sure there's an argument 'hierarchical' => TRUE

share|improve this answer
    
Thank you Delphi, but my CT is already hierarchichal, and Wordpress only let's me set as parent posts with the same content type, not regular Wordpress Pages –  0al0 May 26 '11 at 15:46

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.