• I was wondering if someone could help me through the code needed to create a page template that would display posts from a custom post type.

    Here is the code I am working with:

    <?php /* Template Name: Custom Post Type Archive */
    get_header(); ?>
    
    <?php
    global $query_string;
    query_posts($query_string . "post_type=MY_CPT&post_status=publish&posts_per_page=10");
    if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <?php the_excerpt(); ?>
    
    <?php endwhile;
    endif; ?>
    <div class="navigation">
    	<div class="alignleft"><?php next_posts_link('Previous entries') ?></div>
    	<div class="alignright"><?php previous_posts_link('Next entries') ?></div>
    </div>
    <?php wp_reset_query(); ?>
    
    <?php get_sidebar(); ?>
    <?php get_footer();?>

    I have named the file: archive-MY_CPT.php. I selected this template on the page I want it to display, and when I go to the page there are no posts displaying. What is the problem?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Creating an archive page templaet for use with custom post type’ is closed to new replies.