[wp-hackers] register_post_type not completing with capability_type set to custom value

Tom Jenkins tom at thejenkinsweb.com
Tue Oct 30 16:29:25 UTC 2012


I have the following code to register a custom post type and taxonomy:

            $pcats = array(
                'labels'            => array(
                    'name'          => 'Parts Categories',
                    'singular_name' => 'Parts Category',
                ),
                'show_tagcloud'     => FALSE,
                'hierarchical'      => TRUE,
                'show_in_nav_menus' => FALSE
            );
            register_taxonomy( 'parts-category', 'adc_pfinder', $pcats );

            $labels = array(
                'name'               => 'Parts',
                'singular_name'      => 'Part',
                'add_new_item'       => 'Add New Part',
                'edit_item'          => 'Edit Part',
                'new_item'           => 'New Part',
                'view_item'          => 'View Part',
                'search_items'       => 'Search Parts',
                'not_found'          => 'No parts found',
                'not_found_in_trash' => 'No parts found in Trash',
            );

            $taxonomies   = array( 'parts-category' );
            $supports     = array( 'title', 'editor', 'thumbnail',
'revisions' );

            $post_type_args = array(
                'labels'               => $labels,
                'description'          => 'Parts available for sale by ADS
Members.',
                'public'               => TRUE,
                'exclude_from_search'  => TRUE,
                'publicly_queryable'   => true,
                'show_ui'              => TRUE,
                'show_in_menu'         => TRUE,
                'show_in_nav_menus'    => true,
                'menu_position'        => 25,
                'menu_icon'            => plugins_url(
'/images/parts_spriteslice.png', ASDSPF_PLUGIN_FILE ),
                'capability_type'      => 'adspart',
                'map_meta_cap'         => TRUE,
                'hierarchical'         => FALSE,
                'supports'             => $supports,
                'register_meta_box_cb' => array( &$this, 'meta_boxes' ),
                'taxonomies'           => $taxonomies,
                'has_archive'          => true,
                'rewrite'              => array( 'slug'       => 'part',
                                                 'with_front' => FALSE ),
                'query_var'            => TRUE
            );

            register_post_type( 'adc_pfinder', $post_type_args );


The capability_type is where the failure is occurring. If I change the
capability_type to post the post type shows up and everything works. Trying
to use another value prevents it from working. I need the capability_type
set so I can set user roles around it. Can anyone spot what's wrong here?
I've been banging my head against the wall on this one.

Thanks,

Tom


More information about the wp-hackers mailing list