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.

Having a bit of fun with custom post types.

I use http://generatewp.com/ to generate the following custom post type to record partner organisation records.

Things working:

  • custom post type appears on admin menu
  • categories and tags on both of them (i may delete them later by clearing taxonomies)

What I can't figure out is why the "Add New" menu item is not appearing ... maybe because it's friday and it's been a long week but I cannot see what i'm missing

Anyone?

/* Add Support for CEP Partner records */

if ( ! function_exists('Partners') ) {

// Register Custom Post Type
function Partners() {

    $labels = array(
        'name'                => _x( 'Partners', 'Post Type General Name', 'cep' ),
        'singular_name'       => _x( 'Partner', 'Post Type Singular Name', 'cep' ),
        'menu_name'           => __( 'Partner', 'cep' ),
        'parent_item_colon'   => __( 'Parent Partner', 'cep' ),
        'all_items'           => __( 'Partners', 'cep' ),
        'view_item'           => __( 'View Partner', 'cep' ),
        'add_new_item'        => __( 'Add New Partner', 'cep' ),
        'add_new'             => __( 'New Partner', 'cep' ),
        'edit_item'           => __( 'Edit Partner', 'cep' ),
        'update_item'         => __( 'Update Partner', 'cep' ),
        'search_items'        => __( 'Search Partner', 'cep' ),
        'not_found'           => __( 'No Partners found', 'cep' ),
        'not_found_in_trash'  => __( 'No Partners found in Trash', 'cep' ),
    );
    $rewrite = array(
        'slug'                => 'cep-partners',
        'with_front'          => true,
        'pages'               => true,
        'feeds'               => true,
    );
    $capabilities = array(
        'edit_post'           => 'edit_partner',
        'read_post'           => 'read_post',
        'delete_post'         => 'delete_partner',
        'edit_posts'          => 'edit_partners',
        'edit_others_posts'   => 'edit_others_partners',
        'publish_posts'       => 'publish_partners',
        'read_private_posts'  => 'read_private_partners',
    );
    $args = array(
        'label'               => __( 'partners', 'cep' ),
        'description'         => __( 'CEP Partner Organisations', 'cep' ),
        'labels'              => $labels,
        'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'revisions', 'post-formats', ),
        'taxonomies'          => array( 'category', 'post_tag' ),
        'hierarchical'        => false,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 5,
        'menu_icon'           => '',
        'can_export'          => true,
        'has_archive'         => true,
        'exclude_from_search' => false,
        'publicly_queryable'  => true,
        'query_var'           => 'partners',
        'rewrite'             => $rewrite,
        'capabilities'        => $capabilities,
    );
    register_post_type( 'partners', $args );

}

// Hook into the 'init' action
add_action( 'init', 'Partners', 0 );

}
share|improve this question
    
does the user have the capability publish_partners? –  Milo Aug 26 '13 at 21:32

1 Answer 1

You can't see the menus you expect because the capabilities have not been registered. These:

$capabilities = array(
    'edit_post'           => 'edit_partner',
    'read_post'           => 'read_post',
    'delete_post'         => 'delete_partner',
    'edit_posts'          => 'edit_partners',
    'edit_others_posts'   => 'edit_others_partners',
    'publish_posts'       => 'publish_partners',
    'read_private_posts'  => 'read_private_partners',
);

All of those capabilities with "partner" in them do not exist by default. For a quick test comment that out and you should see the menus. Change "partner" to "post" and things should be editable by the same people who can edit posts (I believe that is the default behavior if you don't pass any capability argument, but I'd have to test it or look it up to be sure.)

You can, of course, create those capabilities, if you'd rather go that route.

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.