Viewing 5 replies - 1 through 5 (of 5 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Are you using a static front page?

    have you got any custom queries on the blog template (index.php ?) without using the ‘paged’ parameter, or using the ‘offset’ parameter?

    http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters

    Thread Starter candlesyp

    (@candlesyp)

    Yes, we are using a static home page. I think…

    This is the code we are using on the index.php page which is the one we are customizing for the blog page:

    <?php if ( have_posts() ) : ?>
                <?php
    global $post;
    $the_newest = get_posts('numberposts=1');
    $the_newer = get_posts('numberposts=3&offset=1'); ?>
    
    <?php foreach($the_newest as $post) :
    setup_postdata($post);	?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <?php the_post_thumbnail(); ?>
    <h1 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>
    <div class="postmeta">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  </div>
    
    <div class="entry">
    <?php the_content('<span>Read on &raquo;</span>'); ?>
    <!-- AddThis Button BEGIN -->
    <div class="addthis_toolbox addthis_default_style addthis_32x32_style">
    <a class="addthis_button_preferred_1"></a>
    <a class="addthis_button_preferred_2"></a>
    <a class="addthis_button_preferred_3"></a>
    <a class="addthis_button_preferred_4"></a>
    <a class="addthis_button_compact"></a>
    <a class="addthis_counter addthis_bubble_style"></a>
    </div>
    <script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>
    <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5124ed6b2f85e2eb"></script>
    <!-- AddThis Button END --> <?php comments_popup_link('No Comments', 'Comment (1)', 'Comments (%)'); ?>
    </div>
    </div>
    <?php endforeach; ?>
    
    <?php foreach($the_newer as $post) :
    setup_postdata($post);	?>
    <div id="blog-excerpt">
    <?php the_post_thumbnail(); ?>
    <h1 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>
    <div class="entry">
    <?php the_excerpt('<span>Read on &raquo;</span>'); ?>
    </div>
    <div class="postmeta">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <!-- AddThis Button BEGIN -->
    <div class="addthis_toolbox addthis_default_style addthis_32x32_style">
    <a class="addthis_button_preferred_1"></a>
    <a class="addthis_button_preferred_2"></a>
    <a class="addthis_button_preferred_3"></a>
    <a class="addthis_button_preferred_4"></a>
    <a class="addthis_button_compact"></a>
    <a class="addthis_counter addthis_bubble_style"></a>
    </div>
    <script type="text/javascript">var addthis_config = {"data_track_addressbar":true};</script>
    <script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5124ed6b2f85e2eb"></script>
    <!-- AddThis Button END --><?php comments_popup_link('No Comments', 'Comment (1)', 'Comments (%)'); ?></div>
    </div>
    <?php endforeach; ?>
    
    			<div class="navigation">
    					<div id="next-ent"><?php next_posts_link('&laquo; Previous Entries') ?></div>
    					<div id="prev-ent"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    				</div>
    
    			</article><!-- #post-0 -->
    
    		<?php endif; // end have_posts() check ?>
    
    		</div><!-- #content -->

    a query with the ‘offset’ paramter does not work with pagination; also ‘get_posts()’ and a ‘foreach’ loop is difficult to paginate.

    if you just want to show the latest post different, there are other methods; for isntance using the loop pointer $wp_query->current_post (starts with 0 zero for the first post in each loop) in a conditional statement;

    your code re-written:
    http://pastebin.com/jswS2FFR

    assumes that the setting – reading – blog pages show at most [ ] posts is set to 4, to get the same result as your code.

    if you want to show the top post on paginated pages small, change this line:
    <?php if( $wp_query->current_post == 0 ) : //latest post// ?>
    to:
    <?php if( $wp_query->current_post == 0 && !is_paged() ) : //latest post// ?>

    Thread Starter candlesyp

    (@candlesyp)

    Thanks Alchymyth that worked! Do you know how to make it so that when previous/next is clicked, there is not a featured blog post at the top, only on the main blog page should the featured blog show up?

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Previous/Next Entries Not Working’ is closed to new replies.