I created a custom post type ("Portfolio") and I can create the posts perfectly fine. The problem is when I go to view the item, it gives me a 404 error.

Here is the portfolio item

Here is my code registering the custom post type:

add_action( 'init', 'create_post_type' );
  function create_post_type() {
    $labels = array(
        'name' => __('Portfolio'),
        'singular_name' => __('Portfolio Item'),
        'add_new' => __('Add New'),
        'add_new_item' => __('Add New Portfolio Item'),
        'edit_item' => __('Edit Portfolio Item'),
        'new_item' => __('New Portfolio Item'),
        'view_item' => __('View Portfolio Item'),
        'search_items' => __('Search Portfolio'),
        '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,
        'supports' => array('title','editor','thumbnail','excerpt','comments')
    register_post_type( 'portfolio' , $args );      

I'm missing something but I don't know what. Help! Thanks in advance :)

  • this happens with a running site... try resseting your permalink struture, save and then reset to your needs.
    – Sagive
    Sep 9, 2013 at 11:46

2 Answers 2


Do the following things and try.

  1. Flush rewrite rules.(Check the link enter link description here).
  2. Update your permalink.

Try to regenerate your permalinks.

Go to Settings / Permalinks and click the Save button.

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.