Static page paging not working

Asked

Viewed 96 times

1

The latest posts and the link paging are appearing, but when I click on link, the URL changes to /page/2/ but gets the same content from the first page.

Does anyone know how I can solve?

<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array( 'post_type' => 'post', 'posts_per_page' => 8, 'paged' => $paged );
    $wp_query = new WP_Query($args);
    while ( have_posts() ) : the_post(); ?>
      <div class="noticia-index">
            <a href="<?php the_permalink(); ?>"><div class="post-thumbnail">
            <?php the_post_thumbnail(); ?>
            </div></a>
            <div class="noticia-index-conteudo"><a href="<?php the_permalink(); ?>"><h2 class="noticia-titulo"><?php the_title(); ?></h2></a>
            <div class="subtitulo-noticia"><?php the_excerpt(); ?></div>
            <span class="icone-time"><img src="<?php echo get_stylesheet_directory_uri(); ?>/img/icones/time-icon.png"></span>
            <span class="time"><?php the_time(); ?></span>
            <span class="icone-comment"><img src="<?php echo get_stylesheet_directory_uri(); ?>/img/comment.png"></span>
            <span class="comments">1</span>
            <a class="leia-mais" href="<?php the_permalink(); ?> ">Leia mais...</a>
        </div>
    </div>
			
<?php endwhile; ?>

<!--  Links de paginação -->
<?php next_posts_link( '&larr; Older posts', $wp_query ->max_num_pages); ?>
<?php previous_posts_link( 'Newer posts &rarr;' ); ?>

  • Gabriel, even though there is a wordpress-only community, If you are asking a question here, you do not need to specify the TAG in the title. If you have noticed correctly, when you click on the questions here in the OS below you already see the tags. So I find it a little unnecessary to emphasize this, considering that everyone knows the goal of tags.

1 answer

0


Browser other questions tagged

You are not signed in. Login or sign up in order to post.