Skip to main content
2 of 2
added 1139 characters in body
Eric
  • 1
  • 1

Permalink Trouble with custom post types

When using custom post types I reach a dilemma where I have to use flush_rewrite_rules(); when using a permalink structure, otherwise it goes to a 404. After using it It works on one CPT but if you have 2 or 3, I still have the same problem and have to back to the basic permalink settting. If you could help me, that would be great.

add_action('init', 'video_register');

function video_register() {

$labels = array(
    'name' => _x('Video', 'post type general name'),
    'singular_name' => _x('Video', 'post type singular name'),
    'add_new' => _x('Add New', 'Video'),
    'add_new_item' => __('Add New Video'),
    'edit_item' => __('Edit Video'),
    'new_item' => __('New Video'),
    'view_item' => __('View Video'),
    'search_items' => __('Search Video'),
    'not_found' =>  __('Nothing found'),
    'not_found_in_trash' => __('Nothing found in Trash'),
    'parent_item_colon' => ''
);

$args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'query_var' => true,
    'menu_icon' => null,
    'rewrite' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'menu_position' => null,
    'taxonomies' => array('post_tag'),
    'supports' => array('title','editor','thumbnail','custom-fields',   'comments',)
    
       ); 

register_post_type( 'video' , $args );
flush_rewrite_rules();
}

This is what I'm adding for my custom post type. Thank you.

Eric
  • 1
  • 1