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 );

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


1 Answer 1


Do not use flush_rewrite_rules() on every init, use it in your plugin’s activation hook once (example).

Side note: __('New Video') is broken. Without the second parameter textdomain this text is not translatable. Use __( 'New Video', 'your_plugin_textdomain' ) instead.

  • Is it possible that you could give me a link that goes more in depth about what you are saying. Im new to this, Thank you.
    – Eric
    Jan 21, 2013 at 4:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.