Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I created a portfolio page to show my works for my theme Everything is ok on my portfolio page, but when I click on an link to go to the portfolio object page, it uses the template's single.php page.

I would like it to use the template page I created "single-portfolio.php". How do I do this?

share|improve this question
1  
A portfolio page, is that a post in a custom post type? –  Mike Madern Jan 17 '13 at 15:16
add comment

2 Answers

up vote 0 down vote accepted

You have to use the Slug of your Custom Post Type "portfolio" for the filename, as you pointed out, single-portfolio.php is correct if your slug is "portfolio".

You just have to take one more step, create the file in the Theme directory (the same folder where your single.php is located).

WordPress automatically selects the single-portfolio.php for the Portfolio CPT if the file is there, and if it is not there, it takes the single.php.

share|improve this answer
    
thanks so much for all –  Chead Jan 17 '13 at 21:11
add comment

The WordPress codex page Template Hierarchy should give you some insight about WordPress theme files naming conventions and how WordPress chooses a certain file and not another:

Graphic Example of the WordPress Template Hierarchy Structure

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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