• Resolved Noel Forte

    (@fortissimo95)


    Hi –

    I’m using the following chunk of code on my front-page.php file to call out my most recent post titles.

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $wp_query = new WP_Query('posts_per_page=5&paged='.$paged);
    ?>
    <?php if(have_posts()) : while (have_posts()): the_post(); ?>
    
    	<section <?php post_class(); ?>>
    		<h1 class="post-title"><a href="<?php the_permalink(); ?>"><?php echo the_title(); ?></a></h1>
    		<h2 class="post-meta">Published on: <?php echo get_the_date('l, F j, Y'); ?></h2>
    	</section>
    
    <?php endwhile; else: ?>
    
    	<?php get_template_part('no-results'); ?>
    
    <?php endif; ?>
    
    <?php echo get_previous_posts_link('Newer Posts'); ?>
    <?php echo get_next_posts_link('Older Posts'); ?>

    However, even though I’m using the paged parameter for my WP_Query, as recommended so many times, this returns the issue of a older posts link that always links to /page/2 with the same content.

    Is there something I’m missing here?

    Thanks,
    Noel

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Pagination issue with paged parameter?’ is closed to new replies.