Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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!

share|improve this question
1  
Since you're hosted by WPEngine, I recommend contacting them directly and asking for advice. It might be that your CPT isn't reliably making it into their cache for some reason, but they can give you a better answer than any of us. –  EAMann Mar 26 '12 at 21:38
    
Thanks, @EAMann. I contacted them already and this was their response: "Change your permalinks, save it, and then set it back. It is quite bizarre but it works. Please let me know if that helps.". That did not work, but I haven't received a comment back from them (about a month now) for another possible solution. Perhaps I will escalate the ticket. –  Jeff Mar 27 '12 at 1:21
    
You should definitely escalate the ticket. If it's an intermittent problem that seems to resolve when you reset the cache, then it's directly related to the cache. And I know WPEngine uses some non-standard code ... so there's nothing we can do to help here. –  EAMann Mar 27 '12 at 1:41
    
Thanks @eamann, I contacted wpengine and it was a caching problem. I don't know how to mark the question as answered since this was a comment, but I appreciate your help. –  Jeff Mar 30 '12 at 12:53
    
Reposted my comments as an answer so you can mark it. –  EAMann Mar 30 '12 at 13:30

1 Answer 1

up vote 0 down vote accepted

Since you're hosted by WPEngine, I recommend contacting them directly and asking for advice. It might be that your CPT isn't reliably making it into their cache for some reason, but they can give you a better answer than any of us.

You should definitely escalate the ticket you've already submitted for the issue. If it's an intermittent problem that seems to resolve when you reset the cache, then it's directly related to the cache. And I know WPEngine uses some non-standard code ... so there's nothing we can do to help here.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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