I just updated to WordPress 3.7 this morning, and I started getting 404 errors on one of my custom post types. I am implementing multiple CPT’s through one plugin. All other CPT’s are wotking fine except one.
The code for the same is below:
// Register Author Post Type
function custom_post_author() {
$labels = array(
'name' => 'Authors',
'singular_name' => 'Author',
'add_new' => 'Add New',
'add_new_item' => 'Add New Author',
'edit_item' => 'Edit Author',
'new_item' => 'New Author',
'all_items' => 'All Authors',
'view_item' => 'View Author',
'search_items' => 'Search Authors',
'not_found' => 'No authors found',
'not_found_in_trash' => 'No authors found in Trash',
'parent_item_colon' => '',
'menu_name' => 'Authors'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'authors' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'menu_icon' => plugins_url( 'images/authors.png', dirname( __FILE__ )),
'supports' => array( 'title', 'thumbnail', 'comments')
);
register_post_type( 'author', $args );
}
add_action( 'init', 'custom_post_author' );
The CPT is visible in the backend, but when I view any post on the frontend it gives a 404.
Any suggestions on how to solve it?
It seems that WordPress 3.7 is not liking the custom post type to be defined as
author
. Changing it toauthors
is working fine. However that will also need an update in the wp_posts table.I had a very similar error: I could not go to any singular page of my custom post types. Updating the permalink settings did not help me either. I debugged a little bit and found out that somehow the rewrites for my custom post types had not been set in the $wp_rewrite->rewrite_rules() array.
All my custom post types are registered within a plugin. Then I remembered that I once read in the documentation that you would have to flush the rules on plugin activation/deactivation (see http://codex.wordpress.org/Function_Reference/flush_rewrite_rules).
So, I fixed my issue by adding flush_rewrite_rules() to the function that registers all my custom post types and I think it will help you too!
I solved this problem using these steps :
Go to paramlink page from
WordPress
‘s menuSettings->paramlinks
and update the settings (don’t need to change any settings) by clicking save changes (or maybe you don’t need to update the settings, only visiting theparamlinks
page is enough) and then try to view your custom posts. It’ll show up.