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'm trying to create a custom post type that I can associate with parent posts (they are posts not pages). Wordpress is version 3.0.1. I was hoping to see a list of posts in a parent post drop-down under Page-Attributes but all I get its an 'Order' field. Have I missed something vital?

register_post_type( 'mytest_post_type',
    array(
        'labels' => array(
                'name' => __( 'mytest Interviews' ),
                'singular_name' => __( 'mytest Interview' ),
                'add_new' => __( 'Add New' ),
                'add_new_item' => __( 'Add New mytest Interview' ),
                'edit' => __( 'Edit' ),
                'edit_item' => __( 'Edit mytest Interview' ),
                'new_item' => __( 'New mytest Int.' ),
                'view' => __( 'View mytest Inteview' ),
                'view_item' => __( 'View mytest Int.' ),
                'search_items' => __( 'Search mytest Interviews' ),
                'not_found' => __( 'No mytest Interviews found' ),
                'not_found_in_trash' => __( 'No mytest Interviews found in Trash' ),
                'parent' => __( 'Parent mytest Interview' ),

        ),
        'public' => true,
        'show_ui' => true,
        'hierarchical' => true,
        'query_var' => true,
        'supports' => array('title', 'editor', 'author','custom-fields','page-attributes'),

    )
);

Or is it not possible to create a new custom post type and have those new posts be children of existing posts?

thanks!

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

This works for me. Looking at the code, the dropdown only appears if the post type is hierarchical (which is true in your case), and if there are other posts of the same type in the database. So a post can not be a child of another post type (a regular post or page for example), and the first new post of a type will not show the dropdown menu.

share|improve this answer
1  
Thanks! That answers my question, though it is not good news. I should look at the source more often. Busy day..... –  codecowboy Oct 7 '10 at 14:17
1  
@codecowboy: Why is this not good news? Did you want to combine posts of different types in one hierarchy? Perhaps that is possible with a minimum amount of work, you could ask a new question about it. –  Jan Fabry Oct 7 '10 at 14:23
    
Yes. I've inherited a site with a strange and badly organised hierarchy. I want to combine posts of different types in one hierarchy but can't switch to page post-types. –  codecowboy Oct 11 '10 at 11:23
    
@codecowboy: Interesting. Certainly worth a new question: "How can I combine posts of different type in one hierarchy?" The post listing would be a challenge, since WordPress normally shows posts per type. –  Jan Fabry Oct 11 '10 at 11:34
    
cool, thanks - I have posted a new question. –  codecowboy Oct 11 '10 at 11:49
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.