[wp-hackers] Please help diagnose custom post type permalink problem

David F. Carr david at carrcommunications.com
Sun Dec 12 01:26:11 UTC 2010


I'm appealing for help diagnosing a problem with a plugin that uses custom
post types. This is the worst type of problem to solve - an intermittent
one. The plugin is working fine for me and for a couple of other people who
have tried it. However, I've had two people report that they get 404 errors
when they try click on the permalinks associated with the posts.

This is an event management plugin. At one point, I thought the 'event' slug
I was using for my custom post type might be clashing with categories or
pages in the permalink hierarchy tagged 'event.' However, I've changed the
slug from 'event' to 'rsvpmaker' and that doesn't seem to have solved the
problem.

The developer I've been corresponding with says it works on one of the
WordPress sites she is managing but not the other. I haven't been able to
figure out what the difference might be. I had her do a data dump of the
contents of the $wp_rewrite object and confirmed that the array of rewrite
directives is being generated properly on the problem system.

Any ideas on how to track this down?

The plugin is posted here:
http://wordpress.org/extend/plugins/rsvpmaker/

The register_post_type code is:

function create_post_type() {

  register_post_type( 'rsvpmaker',
    array(
      'labels' => array(
        'name' => __( 'RSVP Events' ),
        'add_new_item' => __( 'Add New Event' ),
        'edit_item' => __( 'Edit Event' ),
        'new_item' => __( 'Events' ),
        'singular_name' => __( 'Event' )
      ),
    'menu_icon' => WP_PLUGIN_URL.'/rsvpmaker/calendar.png',
	'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'menu_position' => 5,
    'supports' => array('title','editor','author','excerpt'),
	'taxonomies' => array('rsvpmaker-type')
    )
  );


  // Add new taxonomy, make it hierarchical (like categories)
  $labels = array(
    'name' => _x( 'Event Types', 'taxonomy general name' ),
    'singular_name' => _x( 'Event Type', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Event Types' ),
    'all_items' => __( 'All Event Types' ),
    'parent_item' => __( 'Parent Event Type' ),
    'parent_item_colon' => __( 'Parent Event Type:' ),
    'edit_item' => __( 'Edit Event Type' ),
    'update_item' => __( 'Update Event Type' ),
    'add_new_item' => __( 'Add New Event Type' ),
    'new_item_name' => __( 'New Event Type' ),
    'menu_name' => __( 'Event Type' ),
  ); 	

  register_taxonomy('rsvpmaker-type',array('rsvpmaker'), array(
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'rsvpmaker-type' ),
  ));

}

//make sure new rules will be generated for custom post type
add_action('admin_init', 'flush_rewrite_rules');


I include add_action('admin_init', 'flush_rewrite_rules'); to regenerate the
rewrite rules whenever a user is logged in.

Any suggestions about how to figure this out would be appreciated.


More information about the wp-hackers mailing list