WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Currently wordpress "pages" can have a particular page template associated with it. Can this feature also be available for custom post types ?

share|improve this question

You can certainly set up a page template for custom post types. Give this a whirl:

Template Name: Your template name

// Get header
get_header(); ?>

<div id="primary">
<?php // Query post type
$the_query = new WP_Query( array( 'post_type' => 'cpt_name', 'posts_per_page' => -1 ) ); 
if ( $the_query->have_posts() ) : ?>

<?php // Begin loop
while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_excerpt(); ?>

<?php endwhile; ?>

<?php // Reset
wp_reset_postdata(); ?>

<?php else:  ?>
<p><?php _e( 'Please add some content.' ); ?></p>
<?php endif; // End loop and primary ?>

<?php get_footer(); ?>
share|improve this answer
Ah, I see what you mean. I figured that the post-type needs to be set to "hierarchical" – Prakash Raman Mar 26 '14 at 19:27
Cool. You might also want to check this out: codex.wordpress.org/Post_Types#Template_Files – Sam Mar 26 '14 at 19:54

Your Answer


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.