Created a custom post type- can’t view it

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

Read More

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 🙂

Related posts

2 comments

  1. Try to regenerate your permalinks.

    Go to Settings / Permalinks and click the Save button.

Comments are closed.