Intermittent permalink 404s for custom post types. Support desperately required!

Hi Folks,

I've just launched a new website http://www.fundsport.com. Everything was working fine on the live test environment (http://test.fundsport.com) but since the site was migrated, custom post type permalinks are returning a 404. Just to make it that little bit more frustrating, the problem is intermittent, which makes no sense at all to me. Just to reiterate; this is only affecting custom post type posts.

The site is running on WordPress version 3.2.1. It's worth mentioning that upon migration from test to live, I did upgrade WP from 3.2.0 to 3.2.1. It's a standard single site WP installation.

Server Details
Media Temple DVS
Software: Apache/2.2.3 (CentOS)
PHP Version: 5.2.6
MySQL Server: 5.0.45
Memory Limit: 32MB (Site currently uses 49.61%)

See below for custom post type and taxonomy rules defined in functions.php:

// REGISTER CUSTOM POST TYPES
add_action( 'init', 'register_new_post_type' );
function register_new_post_type() {
	register_post_type( 'news',
		array(
			'labels' => array(
				'name' => __( 'News' ),
				'singular_name' => __( 'News' ),
			),
			'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'excerpt' ),
			'public' => true,
			'hierarchical' => true,
			'rewrite' => array('slug' => 'news'),
			'menu_position' => 5,
			'query_var' => true,
		)
	);
	register_post_type( 'advice',
		array(
			'labels' => array(
				'name' => __( 'Advice' ),
				'singular_name' => __( 'Advice' ),
			),
			'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments' ),
			'public' => true,
			'rewrite' => array('slug' => 'advice'),
			'menu_position' => 5,
			'query_var' => true
		)
	);
	register_post_type( 'grants',
		array(
			'labels' => array(
				'name' => __( 'Grants' ),
				'singular_name' => __( 'Grant' ),
			),
			'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields' ),
			'public' => true,
			'rewrite' => array('slug' => 'grants'),
			'menu_position' => 5,
			'query_var' => true
		)
	);
	register_post_type( 'fundraising-ideas',
		array(
			'labels' => array(
				'name' => __( 'Fundraising Ideas' ),
				'singular_name' => __( 'Fundraising Idea' ),
			),
			'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
			'public' => true,
			'rewrite' => array('slug' => 'fundraising'),
			'menu_position' => 5,
			'query_var' => true
		)
	);
	register_post_type( 'case-studies',
		array(
			'labels' => array(
				'name' => __( 'Case Studies' ),
				'singular_name' => __( 'Case Study' ),
			),
			'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
			'public' => true,
			'rewrite' => array('slug' => 'case-studies'),
			'menu_position' => 5,
			'query_var' => true
		)
	);
}

// REGISTER CUSTOM TAXONOMIES
add_action( 'init', 'register_new_taxonomies', 0 );
function register_new_taxonomies() {
	// News
	register_taxonomy( 'location',
		array( 'news' ),
		array(
			'public' => true,
			'labels' => array(
				'name' => __( 'Locations' ),
				'singular_name' => __( 'Location' ),
			),
			'show_ui' => true,
			'show_tagcloud' => true,
			'hierarchical' => true,
			'rewrite' => array('slug' => 'locations'),
		)
	);
	register_taxonomy( 'sport',
		array( 'news' ),
		array(
			'public' => true,
			'labels' => array(
				'name' => __( 'Sports' ),
				'singular_name' => __( 'Sport' ),
			),
			'show_ui' => true,
			'show_tagcloud' => true,
			'hierarchical' => false,
			'rewrite' => true,
		)
	);
	register_taxonomy( 'news_category',
		array( 'news' ),
		array(
			'public' => true,
			'labels' => array(
				'name' => __( 'Categories' ),
				'singular_name' => __( 'Category' ),
			),
			'show_ui' => true,
			'show_tagcloud' => true,
			'hierarchical' => true,
			'rewrite' => array('hierarchical' => 'true', 'slug' => 'cat')
		)
	);
	register_taxonomy( 'news_tag',
		array( 'news' ),
		array(
			'public' => true,
			'labels' => array(
				'name' => __( 'Tags' ),
				'singular_name' => __( 'Tag' ),
			),
			'show_ui' => true,
			'show_tagcloud' => true,
			'hierarchical' => false,
			'rewrite' => array('slug' => 'news_tag'),
		)
	);
	// Advice
	register_taxonomy( 'advice_category',
		array( 'advice' ),
		array(
			'public' => true,
			'labels' => array(
				'name' => __( 'Categories' ),
				'singular_name' => __( 'Category' ),
			),
			'show_ui' => true,
			'show_tagcloud' => true,
			'hierarchical' => true,
			'rewrite' => array('hierarchical' => 'true', 'slug' => 'category', 'with_front' => true),
		)
	);
	register_taxonomy( 'advice_tag',
		array( 'advice' ),
		array(
			'public' => true,
			'labels' => array(
				'name' => __( 'Tags' ),
				'singular_name' => __( 'Tag' ),
			),
			'show_ui' => true,
			'show_tagcloud' => true,
			'hierarchical' => false,
			'rewrite' => array('slug' => 'advice_tag'),
		)
	);
	register_taxonomy( 'media',
		array( 'advice' ),
		array(
			'public' => true,
			'labels' => array(
				'name' => __( 'Media Types' ),
				'singular_name' => __( 'Media Type' ),
			),
			'show_ui' => true,
			'show_tagcloud' => true,
			'hierarchical' => true,
			'rewrite' => array('hierarchical' => 'true', 'slug' => 'media'),
		)
	);
	// Blogs
	register_taxonomy( 'blogs',
		array( 'post' ),
		array(
			'public' => true,
			'labels' => array(
				'name' => __( 'Blogs' ),
				'singular_name' => __( 'Blog' ),
			),
			'show_ui' => true,
			'show_tagcloud' => true,
			'hierarchical' => true,
			'rewrite' => array('hierarchical' => 'true', 'slug' => 'blog'),
		)
	);
	// Grants
	register_taxonomy( 'grant_applicant',
		array( 'grants' ),
		array(
			'public' => true,
			'labels' => array(
				'name' => __( 'Applicants' ),
				'singular_name' => __( 'Applicant' ),
			),
			'show_ui' => true,
			'show_tagcloud' => true,
			'hierarchical' => true,
			'rewrite' => array('hierarchical' => 'true', 'slug' => 'applicant'),
		)
	);
	register_taxonomy( 'grant_location',
		array( 'grants' ),
		array(
			'public' => true,
			'labels' => array(
				'name' => __( 'Location' ),
				'singular_name' => __( 'Location' ),
			),
			'show_ui' => true,
			'show_tagcloud' => true,
			'hierarchical' => true,
			'rewrite' => array('hierarchical' => 'true', 'slug' => 'location'),
		)
	);
	register_taxonomy( 'grant_sport',
		array( 'grants' ),
		array(
			'public' => true,
			'labels' => array(
				'name' => __( 'Sports' ),
				'singular_name' => __( 'Sport' ),
			),
			'show_ui' => true,
			'show_tagcloud' => true,
			'hierarchical' => true,
			'rewrite' => array('hierarchical' => 'true', 'slug' => 'sport'),
		)
	);
	register_taxonomy( 'grant_amount',
		array( 'grants' ),
		array(
			'public' => true,
			'labels' => array(
				'name' => __( 'Amounts' ),
				'singular_name' => __( 'Amount' ),
			),
			'show_ui' => true,
			'show_tagcloud' => true,
			'hierarchical' => true,
			'rewrite' => array('hierarchical' => 'true', 'slug' => 'amount'),
		)
	);
	register_taxonomy( 'grant_type',
		array( 'grants' ),
		array(
			'public' => false,
			'labels' => array(
				'name' => __( 'Grant Types' ),
				'singular_name' => __( 'Grant Type' ),
			),
			'show_ui' => true,
			'hierarchical' => true,
		)
	);
	// Case Studies
	register_taxonomy( 'case_category',
		array( 'case-studies' ),
		array(
			'public' => true,
			'labels' => array(
				'name' => __( 'Categories' ),
				'singular_name' => __( 'Category' ),
			),
			'show_ui' => true,
			'show_tagcloud' => true,
			'hierarchical' => true,
			'rewrite' => array('hierarchical' => 'true', 'slug' => 'case-studies'),
		)
	);
}

The site is currently live and has just launched so I'm counting on you guys do come through (yet again) and save the day. I'm a front-end designer/developer so if you PHP and back-end/server gurus could keep things simple for me that'd be hugely appreciated.

Thanks in advance for your support!

  • Julian Evans
    • Design Lord, Child of Thor

    See my .htaccess rules below:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^fundsport.com [NC]
    RewriteRule ^(.*)$ http://www.fundsport.com/$1 [L,R=301]
    
    # BEGIN WordPress
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_USER_AGENT} !FeedBurner    [NC]
    RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
    RewriteRule ^feed/?([_0-9a-z-]+)?/?$ http://feeds.feedburner.com/fundsport [R=302,NC,L]
    </IfModule>
    
    # BEGIN Compress text files
    SetOutputFilter DEFLATE
    # END Compress text files
    
    # php compression – use with caution
    <ifmodule mod_php4.c>
    php_value zlib.output_compression 16386
    </ifmodule>
    
    # BEGIN Expire headers
    ExpiresActive On
    ExpiresDefault "access plus 1 seconds"
    ExpiresByType image/x-icon "access plus 2592000 seconds"
    ExpiresByType image/jpeg "access plus 2592000 seconds"
    ExpiresByType image/png "access plus 2592000 seconds"
    ExpiresByType image/gif "access plus 2592000 seconds"
    ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
    ExpiresByType text/css "access plus 604800 seconds"
    ExpiresByType text/javascript "access plus 216000 seconds"
    ExpiresByType application/x-javascript "access plus 216000 seconds"
    ExpiresByType text/html "access plus 600 seconds"
    ExpiresByType application/xhtml+xml "access plus 600 seconds"
    # END Expire headers
    
    # BEGIN Cache-Control Headers
    Header set Cache-Control "max-age=2592000, public"
    Header set Cache-Control "max-age=604800, public"
    Header set Cache-Control "max-age=216000, private"
    Header set Cache-Control "max-age=600, private, must-revalidate"
    # END Cache-Control Headers
    
    # BEGIN Turn ETags Off
    Header unset ETag
    FileETag None
    # END Turn ETags Off
    
    # BEGIN Remove Last-Modified Header
    Header unset Last-Modified
    # END Remove Last-Modified Header
    
    #disable hotlinking of images with forbidden or custom image option
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?fundsport.com/.*$ [NC]
    #RewriteRule \.(gif|jpg)$ - [F]
    RewriteRule \.(gif|jpg)$ http://www.fundsport.com/stophotlinking.jpg [R,L]
    
    # END WordPress
  • Mason
    • DEV MAN’s Sidekick

    Hiya,

    That is definitely no fun :slight_frown:

    Can you give me an example 404? (I know it's intermittent) I clicked around and wasn't able to find one. Definitely troubling though and glad to help if I can.

    Did you have a look at your error logs?

  • Julian Evans
    • Design Lord, Child of Thor

    @Mason Hi Mason, if the problem is present it affects all posts that belong to a custom post type simultaneously. So if one post shows a 404 then all posts (except standard posts) will return a 404. I haven't had a look at error logs on the live server, what's the easiest way of enabling error logs?

    @Barry I'm getting WP 404's. I only have 4 plug-ins installed; Cloudflare, WPMU SEO, and Ultimate Facebook. I can't say for definite if the 404s stop showing if I visit the permalinks settings page, but that would definitely make sense as that's usually the first thing I do. Does that help narrow down the cause?

    Thanks guys.

  • Mason
    • DEV MAN’s Sidekick

    Hiya Julian,

    Apologies for the delay, I've been away for several days and am just now getting caught up.

    Are you referring to this plugin?
    http://wordpress.org/extend/plugins/xml-sitemap-feed/

    I can't see how this plugin would impact the permalinks in any way, but it hasn't been updated to work with WP 3.2+ so maybe that has something to do with it? At any rate, if removing the plugin solves the problem, I'd say that's the resolution for now. You could also try mentioning it to that plugin's devs?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.