Advertisement
campusboy

query_posts article

Apr 6th, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.59 KB | None | 0 0
  1. <div class="list-posts">
  2.     <?php
  3.     query_posts( [
  4.         'posts_per_page' => 0,
  5.         'offset'         => get_query_var( 'paged' ),
  6.         'paged'          => get_query_var( 'paged' ),
  7.     ] );
  8.    
  9.     if ( have_posts() ) :
  10.        
  11.         while ( have_posts() ) : the_post(); ?>
  12.  
  13.             <div class="post-item<?php echo is_sticky() ? ' sticky' : ''; ?>">
  14.                 <div class="thumb">
  15.                     <a href="<?php the_permalink(); ?>">
  16.                         <?php oe_the_cat_post_thumbnail(); ?>
  17.                     </a>
  18.                 </div>
  19.                 <div class="preview">
  20.                     <div class="title">
  21.                         <a href="<?php the_permalink(); ?>">
  22.                             <?php the_title(); ?>
  23.                         </a>
  24.                     </div>
  25.  
  26.                     <div class="desc">
  27.                         <?php the_excerpt(); ?>
  28.                     </div>
  29.  
  30.                     <a href="<?php the_permalink(); ?>" class="read-more">Читать далее</a>
  31.                 </div>
  32.             </div>
  33.        
  34.         <?php endwhile;
  35.    
  36.     else : ?>
  37.  
  38.         <p>Статей нет.</p>
  39.    
  40.     <?php endif; ?>
  41. </div><!--/.list-posts -->
  42.  
  43. <?php
  44. // удаляет H2 из шаблона пагинации
  45. add_filter( 'navigation_markup_template', function () {
  46.     ob_start();
  47.     ?>
  48.     <nav class="navigation %1$s" role="navigation">
  49.         <div class="nav-links">%3$s</div>
  50.     </nav>
  51.     <?php
  52.     return ob_get_clean();
  53. } );
  54.  
  55. // выводим пагинацию
  56. the_posts_pagination();
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement