microtag
4/28/2017 - 9:55 AM

Serve per la paginazione nei file single.php e nei single dei custom post.. Modifica la paginazione perchè funzioni From https://wordpress.s

Serve per la paginazione nei file single.php e nei single dei custom post.. Modifica la paginazione perchè funzioni From https://wordpress.stackexchange.com/questions/225024/make-a-custom-loop-inside-single-php-with-pagination

$paged = ( get_query_var( 'page' ) ) ? get_query_var( 'page' ) : 1;

$args = array(
    'posts_per_page'   => 4,
   // quesry
     'paged'         => $paged,
 );

 $posts_relacionados_edicion = new WP_Query( $args );

 if ( $posts_relacionados_edicion->have_posts() ) :

     while( $posts_relacionados_edicion->have_posts() ) :

         $posts_relacionados_edicion->the_post(); ?>

         <div class="col-md-6 col-sm-6">
                 <a href="<?php the_permalink(); ?>" class="blog-titulo-chico"><h3><?php the_title(); ?></h3></a>
              </div>

      <?php endwhile;

      echo paginate_links( array(
          'current' => $paged,
          'total' => $posts_relacionados_edicion->max_num_pages,
          'format' => '?page=%#%'
      ) );

       wp_reset_postdata();

  else : ?>

     <?php _e( 'No found posts.', 'textdomain' ); ?>

  <?php endif; ?>