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've managed to figure out how to use Custom Post Type templates now and they are great. I do however want to know if there is not a way to use a current template I have developed for other pages.

What I have is a page-three-column.php file using conditional checks to see which page it is on and then displaying the relevant content as it needs to.

Rather than copy this html over to the single-product.php template, I want to be able to use the page-three-column.php again as it has all the structure already in place and I wont need to duplicate html and compare it.

Is there a way to "force" wordpress to use a specific template rather than the Custom Post Type template?

I've read through the Codex to see if there is a conditional check one could use and thought that is_single( 'product' ) might work.

Clearly the custom post type template was built to display the content as it is intended but if there is another way, I would appreciate the help?

Many thanks.

share|improve this question
1  
This has been already answered, Here is your solution –  Shazzad Jan 21 at 9:37
add comment

2 Answers 2

You may not completely get out without using a template file. I might be wrong!!. But, by using get_template_part in your single-product.php you will be able to use page-three-column.php file.

So in your single-product.php something like this should do.

<?php get_template_part( 'page-three-column.php' ); ?>

You may refer to the Codex here.

share|improve this answer
    
You don't need to add any templates for CPT's, either single or archive if you don't want custom template files. –  Brad Dalton Jan 21 at 10:17
    
@BradDalton I agree it is not a must. I was suggesting that you need a template to display information. You need a different template if your purpose is different! –  sri Jan 21 at 10:23
add comment

You can use code like this

function portfolio_archive_page_template(){

return locate_template( 'archive-portfolio.php', true );

}

add_filter( 'archive_template', 'portfolio_archive_page_template' );

You can use a conditional for a page template:

is_page_template('your-page-template.php)

For single.php and archive-cpt.php templates, you name the file using the name of the CPT.

single.cpt.php or archive.cpt.php renaming cpt with the name of your cpt.

This page on the Codex pretty much explains it http://codex.wordpress.org/Post_Type_Templates

Along with this http://codex.wordpress.org/Post_Types#Custom_Post_Type_Templates

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.