0

I have a client that wants a blog, a press section, and a "More Posts" section for feel good, community service type of posts. I used the standard post type for the blog, and everything works fine. I registered the two other post types with this code which is within a custom_posts(); function that I add with add_action( 'init', 'custom_posts');

register_post_type( 'press',
    // let's now add all the options for this post type
    array( 'labels' => array(
        'name' => __( 'Press', 'bonestheme' ),
        'singular_name' => __( 'Press', 'bonestheme' ),
        'all_items' => __( 'All Press', 'bonestheme' ),
        'add_new' => __( 'Add New', 'bonestheme' ),
        'add_new_item' => __( 'Add New Post', 'bonestheme' ), 
        'edit' => __( 'Edit', 'bonestheme' ),
        'edit_item' => __( 'Edit Post', 'bonestheme' ),
        'new_item' => __( 'New Post', 'bonestheme' ), 
        'view_item' => __( 'View Post', 'bonestheme' ), 
        'search_items' => __( 'Search Posts', 'bonestheme' ),  
        'not_found' =>  __( 'Nothing found in the Database.', 'bonestheme' ), 
        'not_found_in_trash' => __( 'Nothing found in Trash', 'bonestheme' ), 
        'parent_item_colon' => ''
        ), 
        'description' => __( 'Press', 'bonestheme' ), 
        'public' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'show_ui' => true,
        'query_var' => true,
        'menu_position' => 8, 
        'rewrite'   => array( 'slug' => 'press-posts' ),
        'has_archive' => true, 
        'capability_type' => 'post',
        'hierarchical' => false,
        'supports' => array( 'title', 'thumbnail', 'excerpt', 'revisions', 'sticky', 'custom-fields', 'editor', 'author' )
    )
);

register_post_type( 'more_posts',
    array( 'labels' => array(
        'name' => __( 'More Posts', 'bonestheme' ),
        'singular_name' => __( 'Post', 'bonestheme' ),
        'all_items' => __( 'All Posts', 'bonestheme' ),
        'add_new' => __( 'Add New', 'bonestheme' ),
        'add_new_item' => __( 'Add New Post', 'bonestheme' ), 
        'edit' => __( 'Edit', 'bonestheme' ),
        'edit_item' => __( 'Edit Post', 'bonestheme' ),
        'new_item' => __( 'New Post', 'bonestheme' ),
        'view_item' => __( 'View Post', 'bonestheme' ),
        'search_items' => __( 'Search Posts', 'bonestheme' ),
        'not_found' =>  __( 'Nothing found in the Database.', 'bonestheme' ), 
        'not_found_in_trash' => __( 'Nothing found in Trash', 'bonestheme' ),
        'parent_item_colon' => ''
        ),
        'description' => __( 'More Posts', 'bonestheme' ), 
        'public' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => true,
        'show_ui' => true,
        'query_var' => true,
        'menu_position' => 9,  
        'rewrite'   => array( 'slug' => 'more-posts' ),
        'has_archive' => true, 
        'capability_type' => 'post',
        'hierarchical' => false,
        'supports' => array( 'title', 'thumbnail', 'excerpt', 'revisions', 'sticky', 'custom-fields', 'editor', 'author' ),
    )
);

I am adding the taxonomies with this code, also in the custom_posts(); function:

    register_taxonomy( 'press_cat', 
    array('press'), /* if you change the name of register_post_type( 'press', then you have to change this */
    array('hierarchical' => true,     /* if this is true, it acts like categories */
        'labels' => array(
            'name' => __( 'Categories', 'bonestheme' ), /* name of the custom taxonomy */
            'singular_name' => __( 'Press Category', 'bonestheme' ), /* single taxonomy name */
            'search_items' =>  __( 'Search Press Categories', 'bonestheme' ), /* search title for taxomony */
            'all_items' => __( 'All Press Categories', 'bonestheme' ), /* all title for taxonomies */
            'parent_item' => __( 'Parent Press Category', 'bonestheme' ), /* parent title for taxonomy */
            'parent_item_colon' => __( 'Parent Press Category:', 'bonestheme' ), /* parent taxonomy title */
            'edit_item' => __( 'Edit Press Category', 'bonestheme' ), /* edit custom taxonomy title */
            'update_item' => __( 'Update Press Category', 'bonestheme' ), /* update title for taxonomy */
            'add_new_item' => __( 'Add New Press Category', 'bonestheme' ), /* add new title for taxonomy */
            'new_item_name' => __( 'New Press Category Name', 'bonestheme' ) /* name title for taxonomy */
        ),
        'show_admin_column' => true, 
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'press-posts-category' )
    )
);
register_taxonomy( 'more_cat', 
    array('more_posts'), /* if you change the name of register_post_type( 'more-posts', then you have to change this */
    array('hierarchical' => true,     /* if this is true, it acts like categories */
        'labels' => array(
            'name' => __( 'Categories', 'bonestheme' ), /* name of the custom taxonomy */
            'singular_name' => __( 'Post Category', 'bonestheme' ), /* single taxonomy name */
            'search_items' =>  __( 'Search Posts Categories', 'bonestheme' ), /* search title for taxomony */
            'all_items' => __( 'All Posts Categories', 'bonestheme' ), /* all title for taxonomies */
            'parent_item' => __( 'Parent Posts Category', 'bonestheme' ), /* parent title for taxonomy */
            'parent_item_colon' => __( 'Parent Posts Category:', 'bonestheme' ), /* parent taxonomy title */
            'edit_item' => __( 'Edit Posts Category', 'bonestheme' ), /* edit custom taxonomy title */
            'update_item' => __( 'Update Posts Category', 'bonestheme' ), /* update title for taxonomy */
            'add_new_item' => __( 'Add New Posts Category', 'bonestheme' ), /* add new title for taxonomy */
            'new_item_name' => __( 'New Posts Category Name', 'bonestheme' ) /* name title for taxonomy */
        ),
        'show_admin_column' => true, 
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'more-posts-category' )
    )
);

Press - archive is broken(404) when using custom permalinks (works fine with std perma)

More - archive is broken(404) when using custom permalinks (works fine with std perma)

More - category gives me a page, but returns no posts (there are 2 posts in there)

I am using this plugin to create the archive and category lists on the sidebar, it seems to be functioning correctly. The URLs it gives me are:

/press/2015/02/ - press archives

/more_posts/2015/02/ - more archive

/more-posts-category/giving-back/ - more categories

2
  • 1
    what action do you call this code on? and what urls are you visiting to see your archives? – Milo Feb 27 '15 at 1:22
  • Updated above with answers – Alex Chastain Feb 27 '15 at 18:01
0

Custom post type archives don't have year/month rewrite rules, they only have a single archive which will be at /press/ and /more_posts/. If you want those, you'll have to add them yourself. For the taxonomy, add the taxonomies argument to your post type registration to insure the two objects are connected, see the note about this on register_post_type.

1
  • Sorry, it's difficult to tell what code is relevant to put up for the purpose of the question. I was actually already adding the taxonomies. I updated my question above. – Alex Chastain Feb 27 '15 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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