0

I'm trying to create a custom post type that's supposed to be used for a publication issue -> article structure. Since the hierarchical structure is really only meant for pages (refer to hierarchical section's note), I figured I'd configure the custom post type to act as a page.

Great, except I can't get it to work properly. Even after setting capability_type to page and hierarchical to true, the edit screen for the post type is still acting as though it's a post. There aren't any "parent" or "page template" attribute drop down menus.

If I change the capability_type from page to post, literally nothing changes with the edit screen.

Here's my code:

register_post_type('publication', array(
    'label' => 'Publication',
    'public' => true,
    'show_ui' => true,
    'show_in_menu' => true,
    'capability_type' => 'page',
    'map_meta_cap' => true,
    'hierarchical' => true,
    'rewrite' => array('slug' => 'publication', 'with_front' => true),
    'query_var' => true,
    'supports' => array('title','editor','comments','revisions','author','page-attributes'),
    'labels' => array (
        'name' => 'Publications',
        'singular_name' => 'Publication',
        'menu_name' => 'Publications',
    )
));

Any ideas what's wrong here?

1
  • 1
    First of all... Capability_type has nothing to do with this. It's used to construct permissions. Do you have any plugins enabled on this site? Commented Apr 12, 2014 at 20:57

2 Answers 2

2

I've taken this from another site I have made which uses the hierarchical structure and it works. (I have amended to fit your post type)

function register_publications_cpt() {

        $labels = array(
            'name' => _x('Publications', 'post type general name'),
            'singular_name' => _x('Publication', 'post type singular name'),
            'add_new' => _x('Add New', ''),
            'add_new_item' => __('Add New Publication'),
            'edit_item' => __('Edit Publication'),
            'new_item' => __('New Publication'),
            'all_items' => __('All Publication'),
            'view_item' => __('View Publication'),
            'search_items' => __('Search Publications'),
            'not_found' =>  __('No Publications found'),
            'not_found_in_trash' => __('No Publications found in Trash'), 
            'parent_item_colon' => '',
            'menu_name' => 'Publications'
        );

        $args = array(
            'hierarchical' => true,     
            'labels' => $labels,
            'public' => true,
            'publicly_queryable' => true,
            'show_ui' => true, 
            'show_in_menu' => true, 
            'query_var' => true,
            'rewrite' => true,
            'capability_type' => 'page',
            'has_archive' => false, 
            'menu_position' => 22,
            'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'revisions', 'page-attributes', 'custom-fields' )
        ); 

        register_post_type('publication', $args);

}
add_action('init', 'register_publications_cpt');
7
  • Still no luck. I thought this was strange because I've too done this exact thing before, but yet on this site, it's not working. Would there be any site configuration option that could be messing this up?
    – scferg5
    Commented Mar 7, 2014 at 14:56
  • Have you done the usual, disable all plugins and switch to a default theme i.e twentythirteen? Commented Mar 7, 2014 at 14:59
  • Yes. No plugins, Twentythirteen theme (with CPT code added to functions.php), still not working. Strange...
    – scferg5
    Commented Mar 7, 2014 at 15:04
  • Can you see my amended answer and see if that works? Commented Mar 7, 2014 at 15:12
  • Nothing :/ I've even tried using the Custom Post Type UI addon and that doesn't work either.
    – scferg5
    Commented Mar 7, 2014 at 15:16
1

Old question but I was looking for the answer myself...

You need two things here when creating your post type to fix this:

'hierarchical' => true,
'supports' => array('page-attributes'),

That will give you a template select and an order menu.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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