Lovely 404 Issue w/ Custom Post Type – take a look
-
I’m trying to rewrite my permalinks using meta data from my post. The permalink rewrite works- but I’m getting the 404 issue.
I’ve flushed by visiting the permalink settings page, and still no dice.
Could someone offer a clue as to why this wouldn’t work?
add_filter('post_type_link','calendar_link_filter',1,3); function calendar_link_filter( $post_link, $id = 0, $leavename = FALSE ) { $post = get_post($id); if($post->post_type != 'super_duper') { return $post_link; } $date = get_post_meta($post->ID,'event_start_date',true); $date = strtotime($date); $str = $post_link; $str = str_replace('%cal_year%',date("Y",$date),$str); $str = str_replace('%cal_month%',date("m",$date),$str); $str = str_replace('%cal_day%',date("d",$date),$str); return $str; } add_action( 'init', 'create_my_post_types' ); function create_my_post_types() { register_post_type( 'super_duper', array( 'labels' => array( 'name' => __( 'Super Dupers' ), 'singular_name' => __( 'Super Duper' ) ), 'hierarchical' => false, 'show_ui' => true, // UI in admin panel 'public' => true, 'rewrite' => array('slug' => 'events/%cal_year%/%cal_month%/%cal_day%'), ) ); }
- The topic ‘Lovely 404 Issue w/ Custom Post Type – take a look’ is closed to new replies.