I created a custom post type called portfolio. I also created a file called single-portfolio.php to display the portfolio content.

When creating a portfolio post, the template I want to use doesn't show up in the dropdown list under the Attributes section. In fact, the dropdown list doesn't show up at all until I create my first portfolio post, at which point, the dropdown list is populated with two items:

-(no parent)

-[Title of the first Portfolio post]

Here's what's in functions.php

add_action('init', 'create_portfolio');
function create_portfolio() {
$labels = array(
    'name' => _x('My Portfolio', 'post type general name'),
    'singular_name' => _x('Portfolio Item', 'post type singular name'),
    'add_new' => _x('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'),
    'not_found' =>  __('Nothing found'),
    'not_found_in_trash' => __('Nothing found in Trash'),
    'parent_item_colon' => ''
$portfolio_args = array(
    'labels' => $labels,
    'label' => __('Portfolio'),
    'singular_label' => __('Portfolio'),
    'public' => true,
    'show_ui' => true,
    'capability_type' => 'post',
    'hierarchical' => true,
    'has_archive' => true,
    'rewrite' => array("slug" => "portfolio"),
    'can_export' => true,
    'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'page-attributes')

And single-portfolio.php

Template Name: Single Portfolio
<?php get_header(); ?>
<div id="main">
<?php $loop = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => 10)); 
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
    $custom = get_post_custom($post->ID);
    $screenshot_url = $custom["screenshot_url"][0];
    $website_url = $custom["website_url"][0];
    $date_completed = $custom["date_completed"][0];
    <div id="portfolio-item">
<h1><?php the_title(); ?></h1>
<?php echo 'Completed:'; $custom["year_completed"][0]; ?>
<a href="<?=$website_url?>"><?php the_post_thumbnail(); ?> </a>
<?php the_content(); ?>
    <?php endwhile; ?>

<?php get_sidebar(); ?>
<?php get_footer(); ?>

1 Answer 1


I think you are a bit confused as to what Page Attributes will give you access to. To the best of my knowledge you do not get a drop down to choose a template (as you do on Pages) as an automatic function on custom post types.

That being said, you are on the right track. You need to make an archive-portfolio.php file as well to display all of the portfolio posts as well.

You do not need an additional WP_Query to pull in your correct post type - WordPress will do that correctly based on single-POSTTYPE.php.

Ditch that line and revert to the standard loop - and ditch the template name as well. It does not do anything. If you really, really, really want to use this as a Page, rename the template page-portfolio.php and create a page, select this template and you'll be off like a shot.

  • You're right. I was kinda confused. What I wound up doing was going ahead and creating the file page-portfolio.php and selecting the template. So far, I'm getting the results I want. Thanks for your help!
    – Joseph
    Mar 29, 2012 at 5:05

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.