Advertisement
alchymyth

double loop

May 15th, 2016
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.57 KB | None | 0 0
  1. <div class="owl-carousel" >
  2.     <?php
  3.       $args = array (
  4.         'posts_per_page' => 3,
  5.         'cat' => '-36'
  6.       );
  7.     $entradasDestacadas = new WP_Query($args);
  8.     if($entradasDestacadas-> have_posts());
  9.       while($entradasDestacadas-> have_posts()) : $entradasDestacadas-> the_post();
  10.       $do_not_duplicate[] = $post->ID;
  11.     ?>
  12.     <?php get_template_part( '/template-parts/blog-entries-featured', get_post_format() ); ?>
  13.     <?php
  14.       endwhile;  
  15.       wp_reset_postdata();
  16.     ?>
  17.     </div>
  18.  
  19.     <div class="not-featured">
  20.     <h3>Entradas Anteriores</h3>
  21.         <?php
  22.       $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  23.         $args = array (
  24.           'cat' => '-36',
  25.           'paged' => $paged,
  26.           'posts_per_page' => 6,
  27.           'post__not_in' => $do_not_duplicate
  28.         );
  29.       $entradasAnteriores = new WP_Query($args);
  30.         if ($entradasAnteriores-> have_posts() ) :
  31.             /* Start the Loop */
  32.             while ($entradasAnteriores-> have_posts() ) : $entradasAnteriores-> the_post();
  33.           if ( in_array( $post->ID, $do_not_duplicate ) ) continue;
  34.       ?>
  35.         <?php get_template_part( '/template-parts/blog-entries', get_post_format() ); ?>
  36.    <?php
  37.   endwhile;
  38.   wp_reset_postdata(); ?>
  39.  
  40.   <div class="pagination">
  41.     <div class="btn nav-prev"><?php next_posts_link(__('Más antiguas', 'thematic'),$entradasAnteriores->max_num_pages) ?></div>
  42.     <div class="btn nav-next"><?php previous_posts_link(__('Más recientes', 'thematic'),$entradasAnteriores->max_num_pages) ?></div>
  43.   </div>
  44.  
  45.  </div>
  46.  
  47.     <?php
  48.         endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement