0

I have a site with 5 Custom Post Types... and 4 of them are working perfectly. What am I doing wrong?

I have declared this fifth Custom Post Type in exactly the same way I declared all my previous Custom Post Types. It appears in the Admin window, I can create posts, I can even see those posts in the Appearances > Menu screen... but when I visit that section on the site, it displays the 404 from index.php (instead of archive.php -- really odd).

Additionally I have menu_position set to 9 (with the others working backwards to 5) and it still appears below Media in the Admin menu... another mystery that might be related. (In the documentation Media is 10.)

enter image description here

You can see the code that declares the post type here:

function custom_post_street() {
    $labels = array(
        'name'               => _x( 'Street', 'post type general name' ),
        'singular_name'      => _x( 'Street', 'post type singular name' ),
        'add_new'            => _x( 'Add New', 'Street' ),
        'add_new_item'       => __( 'Add New Street Post' ),
        'edit_item'          => __( 'Edit Street Post' ),
        'new_item'           => __( 'New Street Post' ),
        'all_items'          => __( 'All Street Posts' ),
        'view_item'          => __( 'View Street Post' ),
        'search_items'       => __( 'Search Street Posts' ),
        'not_found'          => __( 'No Street Posts found' ),
        'not_found_in_trash' => __( 'No Street Posts found in the Trash' ),
        'parent_item_colon'  => '',
        'menu_name'          => 'Street'
    );
    $args = array(
        'labels'        => $labels,
        'description'   => 'Holds Street post specific data',
        'public'        => true,
        'menu_position' => 9,
        'supports'      => array( 'title', 'editor', 'thumbnail', 'comments' ),
        'has_archive'   => true
    );
    register_post_type( 'street', $args );
}
add_action( 'init', 'custom_post_street' );

Given the odd placement of the menu in the Admin section I've double checked the the logic works out, and read all the documentation on the Custom Post Type page.

I've tried emptying all my caches and deactivating my plugins, but nothing has made any difference. I feel like I'm missing something obvious, but I can't figure out what!

2
  • 1
    Try re-saving your permalink settings. It will flush all rewrite rules. It helped me on a 3.x.x version, while I was having the 404 error. Commented Feb 1, 2016 at 2:05
  • Agh! That was it! (Although Street still appears below Media, but that's minor.) THANK YOU! Commented Feb 1, 2016 at 2:08

1 Answer 1

-1

Try to change position : 'menu_position' => 18,

2
  • 2
    Try explaining why changing menu position to 18 will work. This should be in a comment. Commented Feb 1, 2016 at 10:50
  • Some time 3rd party plugins take same position .... like as contact from 7. . i solved to change menu position ... Commented Feb 2, 2016 at 5:58

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.