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'd like to create a custom post type and add this as a child post of some but not all existing standard posts (which are not pages). Is this possible?

Can I, for example, create a custom post type and then include this in other posts using a shortcode? Is there a better way to do this using custom taxonomies?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

Is there a better way to do this using custom taxonomies?

You're right on the money there. Rather than try to make a custom post into the child of a standard post (because you can't), I'd recommend using a custom taxonomy to order things.

Essentially, you could build a custom hierarchical taxonomy and use it to "categorize" both standard posts and custom posts. You'd mark your standard posts as the parent in the taxonomy and your custom posts as the child.

A second option

Another option would be to use a custom field for parental inheritance. This might be a bit faster to code and more intuitive to use (plus it will give you some added control).

Add a custom meta field to your custom post type called "parents." This can then be a list of post IDs the child post should be nested under. When you need to call up the list, you can do a quick query to SELECT all of your custom posts that have the parent ID in question in their "parents" list.

share|improve this answer
    
thanks for your reply. Option 1 - could you maybe expand on that? Let's say I have News posts and I sometimes want to have a 'subpost' which is an interview with someone about the topic. My news posts are already categorized using standard WP categories –  codecowboy Oct 11 '10 at 14:56

Can I, for example, create a custom post type and then include this in other posts using a shortcode? Is there a better way to do this using custom taxonomies?

<?php query_posts( array( 'post_type' => array('post', 'CUSTOM_POST_TYPE_HERE') ) ); ?>

Put this in the relevant template above if(have_posts()). This will allow both posts and your custom type to be shown.

share|improve this answer

I think the Posts 2 Posts plugin does what you need to do. You will have to write some of the logic yourself, but it provides a nice API for many-to-many relationships between posts (of any type).

share|improve this answer

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.