3

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?

3 Answers 3

2

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.

1
  • 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 Commented Oct 11, 2010 at 14:56
0

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).

0

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.