WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I just updated a site to 3.1 that uses several custom post types.

When I had made the site I had not noticed at the time the $post_type parameter for register_post_type has to be in all lowercase letters! ( it was not well written in the codex but now it is bold). http://codex.wordpress.org/Function_Reference/register_post_type#Parameters

My custom post types were registered with a capitol letter for instance "Rentals" instead of 'rentals'. This was fixed in 3.1 thus any posts registered with upper case letters were totally broken in the back and front end.

I was able to go back into the function and change it to lowercase and then call another function to update the database with the new name before it fires thanks to a post on wordpress.org by dennis_f.

Here new function

global $wpdb;
$wpdb->query("UPDATE $wpdb->posts SET post_type = 'custom-rental' WHERE post_type = 'Custom-Rental'");

and here is the register re-written in lowercase

// Custom page template for rentals      -----------------
function Rental_register_post_type() {
    register_post_type( 'custom-rental', array(
        'public'        => true,
        'can_export'    => true,
        'has_archive'   => 'Rentals',
        'rewrite'       => true,
        'supports' => array(
                ** bunch of supports stuff
        'labels' => array(
            **bunch of labels
add_action( 'init', 'Rental_register_post_type', 0 );

This did fix the major issue of broken custom post types BUT the problem is now using a custom permalink structure breaks the custom post type 'rentals', only the default works.

For example www.example.com/?custom-rental=7-bedrooms works fine, but no custom permalink structure works, I have tried each type and cleared the .htaccess and just returns a 404.

Any ideas?

share|improve this question
Can you show example URLs that don't work? Did you flush your permalinks? Also I note your value fro 'has_archive' is still not lowercase? – MikeSchinkel Mar 5 '11 at 22:10
Wow Mike I did flush the permalinks. But after reading your comment I though wth I'll click it 2x, second click flushed it and it works. – Wyck Mar 5 '11 at 23:30
up vote 2 down vote accepted

To avoid this from happening simply add flush_rewrite_rules( false ); after your register_post_type function. you can read about it more here http://en.bainternet.info/2011/custom-post-type-getting-404-on-permalinks

share|improve this answer

Your Answer


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.