I want to create a page to display all the 9 recent posts within that custom post type. (this is where I'm getting confused) I've called the page template page-podium.php ( my custom post type is podium, see below )

My page-podium.php kind of works. It displays them but I'm having trouble getting the pagination to work, is it in the correct place? it seems to multiply the links over and over.

And lastly. when i click on the custom post type post to go to the actual page it says "Page not found", this is the bit im confused the most about, is it loading them via page.php or single.php? or do i need a page-podium-page.php or something?

Here's my code...

Post Type Podium:

add_action( 'init', 'create_post_type' );
function create_post_type() {
    register_post_type( 'podium',
            'labels' => array(
                'name' => __( 'Podiums' ),
                'singular_name' => __( 'Podium' ),
            'public' => true,
            'has_archive' => true,
            'supports' => array( 'title', 'thumbnail', 'custom-fields' ),
            'taxonomies' => array('category'),

Page Template

 * Template Name: The Podium
 * The 'Gallery' Page for the podium posts.
<?php get_header(); ?>

          <article class="podium col-sm-12 col-md-12">

            <h1>The Podium</h1> 

               <?php query_posts( 'post_type=podium&posts_per_page=3'); ?>
              <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

                <li class="col-sm-6 col-md-4 col-lg-3">
                  <a href="<?php the_permalink(); ?>">
                    <?php if (has_post_thumbnail( $post->ID ) ): ?>
                    <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnails' ); ?>
                    <img src="<?php echo $image[0]; ?>">
                    <?php endif; ?>

            <?php endwhile; else : ?>

            <div class="alignleft"><?php previous_posts_link('&laquo; Previous') ?></div>
    <div class="alignright"><?php next_posts_link('More &raquo;') ?></div>
            <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>

            <!-- REALLY stop The Loop. -->
           <?php endif; ?>

          </article><!-- Article End -->                  



<?php get_footer(); ?>
  • 1
    Please don't use external links to add your code. You can add your code directly into the question which will be easier for viewers. For formatting help you can review How to Format Posts. I've went ahead and modified your question to add your code so that you get the idea of what it looks like. – Howdy_McGee Dec 29 '14 at 18:13
  • if you want to add pagination on your custom post template then CPTPagination i think help you – Amit Mishra Dec 29 '14 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.