Support » Fixing WordPress » Next/previous page not working for custom post types only

  • Resolved SchuminWeb

    (@schuminweb)


    Having a problem with making the “next page” links work under my custom post types only. Everything works just fine for regular post types.

    What happens is that for my custom posts, if one clicks on the “next page” or “previous page” links, the correct URL will display and the navigation links will adjust accordingly, but the content is still the first page.

    Here’s a page with an example of what it’s doing:

    Main page for custom post type: http://falcon.schuminweb.info/archives/site-updates/
    Second page for custom post type: http://falcon.schuminweb.info/archives/site-updates/page/2/

    Same content.

    Here’s the code I’m using for this custom post type:

    <?php
    global $query_string;
    query_posts("post_type=site_updates&post_status=publish&posts_per_page=50");
    if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <p><B><?php the_time('F j, Y'); ?>, <?php the_time('g:i A'); ?></B> – <?php the_content (); ?></p>
    
    <?php endwhile;
    endif; ?>

    Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Posting the full PHP per an off-board request:

    <?php
    /*
    Template Name: Archives (Site Updates)
    */
    ?>
    
    <?php get_header(); ?>
    
    <?php get_template_part('sidebar-archives'); ?>
    
    <?php remove_filter ('the_content',  'wpautop'); ?>
    
    <div id="content">
    
    <h2 class="centerparagraph"><?php the_title(); ?></h2>
    
    <?php
    global $query_string;
    query_posts("post_type=site_updates&post_status=publish&posts_per_page=50");
    if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <p><B><?php the_time('F j, Y'); ?>, <?php the_time('g:i A'); ?></B> – <?php the_content (); ?></p>
    
    <?php endwhile;
    endif; ?>
    
        <div id="updatenavigation">
    	<hr />
    
        <div id="updatenavigationleft">
        <?php next_posts_link('Previous entries') ?>
        </div>
    
        <div id="updatenavigationright">
    	<?php previous_posts_link('Next entries') ?>
        </div>
    
        </div>
    
    <?php wp_reset_query(); ?>
    
    </div>
    
    <?php get_footer();?>

    $query_string should already contain the proper page parameter; try tossing it into your query parameters:

    global $query_string;
    query_posts( $query_string . '&post_type=site_updates&post_status=publish&posts_per_page=50' );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Next/previous page not working for custom post types only’ is closed to new replies.