Hello I am working on a project where I need to have custom post types. Creating the post types and making them show up in my admin menu was a walk in the park using the following:

add_action( 'init', 'create_post_type' );

function create_post_type() {
    register_post_type( 'Portfolio',
            'supports' => array('title', 'editor', 'thumbnail','excerpt'), 
            'labels' => array(
                'name' => __( 'Portfolio' ),
                'singular_name' => __( 'Portfolio' ),
        'taxonomies' => array('category', 'post_tag'), 
        'public' => true,
        'has_archive' => true,

I have created a number of custom posts and all of them get their own perma link.


Resulting in


However whenever I view this permalink it loads my index.php file instead of the custom post belonging to this link. The same happens when I try to load http://www.mydomain.com/subdomain/custom-post-type to access the archive page: it loads my index.php file.

I already tried the following:

  • Visiting the permalink setting within wordpress
  • Deleting all pages with slug in common width my custom pages
  • Deleting all categories with name in common with my custom pages


  • I have no custom taxonomy as far as i know. So I did not register any. I only have a custom meta box with radio buttons being saved to the post meta
  • I called: require_once(ABSPATH .'wp-includes/pluggable.php'); to solve an issue with the post meta

conclusion: I did all this without success. Have been looking for a solution for more than a day now. So i guess it's time to call in the reinforcements. Does anyone have a clue how to solve this and save my day? Thanks in advance!

  • change post type Portfolio to portfolio register_post_type($post_type, $args); $post_type (string) (required) Post type. (max. 20 characters, can not contain capital letters or spaces)
    – Anjum
    Aug 20, 2013 at 11:16

1 Answer 1


post_type needs to be max. 20 characters, can not contain capital letters or spaces, in register_post_type(); function your post type name is capitalize Portfolio replace with lower letters portfolio

this is my register post type snippet, follow it

// add action register our post type portfolio
add_action( 'init', 'register_cpt_portfolio' );

// Register our Custom Post type as portfolio
function register_cpt_portfolio() {

    // labels text for our post type portfolio
    $labels = array(
        // post type general name
        'name' => __( 'Portfolio' ),
        // post type singular name
        'singular_name' => __( 'Portfolio Item' ),
        'add_new' => __( 'Add New Portfolio Item' ),
        '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 Items' ),
        'not_found' =>  __( 'No Portfolio Items found' ),
        'not_found_in_trash' => __( 'No Portfolio Items found in Trash' ),
        'parent_item_colon' => '',
        'menu_name' => 'Portfolio'

    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'has_archive' => true,
        'menu_position' => 5,
        'supports' => array( 'title', 'editor', 'thumbnail', 'author', ),
        'rewrite' => array( 'slug' => 'portfolio-item', 'with_front' => false )
    register_post_type( 'portfolio' , $args );
  • thanks for the answer! I will work with this for now. I'll let you know how it turns out! Aug 20, 2013 at 11:49
  • Please explain how this code is different from the OP's, why it works, and why the OP's doesn't work. Aug 20, 2013 at 13:57
  • @Chip Bennett i have edited my answer with some information why their (asker) code was not working.
    – Anjum
    Aug 20, 2013 at 14:44
  • 1
    Anjum, I fixed the issue. Thanks for your help. I used your code since i'm quite new to wordpress coding and your code was very understandable. However it did not quite solve the issue. I was writing my own plugin and somewhere in that plugin i wrote the following: 'if(is_admin())'. That very line there made my pages unavailable but it did make them show up in my admin menu. Totally ignorant of me to ignore the fact that i wrote that line in this problem. I am grateful for your help! I will edit my post with the final details for anyone stumbling upon this question! Aug 20, 2013 at 15:43

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.