I can't stop my custom post types from sporadically 404ing.
It doesn't always happen and I can't predictably replicate the problem - as in sometimes it happens, sometimes it doesn't. However, once I clear the cache, the 404 always goes away and the URL works.
I have tried resetting and re-saving the permalinks, which are currently category/postname.
I have also tried playing around with the flush rewrite rules, setting them to blank and false, but nothing seems to cure the issue.
Here is my current code:
add_action('init', 'create_raceresults_post_type');
function create_raceresults_post_type() {
register_post_type('raceresults', array(
'labels' => array(
'name' => 'Race Results',
'singular_name' => 'Race Results',
'add_new' => 'Add New Race Result',
'add_new_item' => 'Add New Race Result',
'edit' => 'Edit Race Result',
'edit_item' => 'Edit Race Result',
'new_item' => 'New Race Result',
'view_item' => 'View Race Result',
'search_items' => 'Search Race Result',
'not_found' => 'No Race Result found',
'not_found_in_trash' => 'No Race Result found in Trash'
),
'public' => true,
'exclude_from_search'=> false,
'rewrite' => array('slug' => 'best-running-training-program', 'with_front' => true),
'supports' => array(
'title',
'excerpt',
'title',
'excerpt',
'editor',
'custom-fields',
'revisions',
'thumbnail',
'author',
'page-attributes'
),
'taxonomies' => array('category', 'post_tag') // this is IMPORTANT
));
flush_rewrite_rules();
}
Is there something I am missing or not trying? Here is an example of that custom post: http://runnersconnect.net/best-running-training-program/race-results-march-24-march-25/. I just tried it and it worked when I first published 60 minutes ago but just 404ed when I tried to check it.
Thanks in advance!