J
J
jazzman72018-05-02 01:23:16
WordPress
jazzman7, 2018-05-02 01:23:16

How to make pagination with wp_query?

Good day. Can you please tell me how to add pagination here?

<?php
/*
Template Name: Шаблон блогов
*/
 get_header(); ?>

<div class="csect1">
<div class="title">Следим за миром дизайна</div>
<p><a class="bot2" href="#modal">Получить совет</a></p>
</div>

<div class="container">
  <div class="row">
    <div class="col-md-9">
<?php $wpb_all_query = new WP_Query(array('post_type'=>'post', 'post_status'=>'publish', 'posts_per_page'=>1)); ?>

<?php if ( $wpb_all_query->have_posts() ) : ?>
<?php while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post(); ?>
<div class="arc">
      <div class="scontent">
        <div class="post-detail-01 style-02">
 <!-- <a href="<?php the_permalink(); ?>">-->

          <div class="title">
            <h1>
              <?php the_title(); ?>
            </h1>
            <div style="margin-top:1%;">
              <span>
              <?php the_date('d.m.Y'); ?>
              </span>
             </div>
          </div>
          <div class="content">
    <?php 
    
    the_post_thumbnail('full', array('class' => 'miniature5')); 

?>
<?php mayak_announcement('mayak_segment_length','mayak_segment_more'); ?>
<a href="<?php the_permalink(); ?>"><span class="mayak-more">Читать продолжение</span></a>

  </div>   
   </div></div></div>
<!-- </a> -->

<?php endwhile; ?>
  <!-- end of the loop -->



  <?php wp_reset_postdata(); ?>

<?php else : ?>
  <p><?php _e( 'Извините, нет записей, соответствуюших Вашему запросу.' ); ?></p>
<?php endif; ?>

      <?php if (function_exists("emm_paginate")) {
        emm_paginate();
      } ?>

    
       <div class="pcontent">
      <h3>Другие записи</h3>
      
      <div class="row">
   <?php $posts = get_posts('orderby=rand&numberposts=6');
foreach($posts as $post) { ?>
        
      <a class="call0" href="<?php the_permalink(); ?>">
      <div class="call2">
        <?php 
    
    the_post_thumbnail('medium', array('class' => 'miniature2')); 

?>
     
          <?php the_title(); ?>
        
      </div>
      </a>
      <?php

}
?>
</div><div class="clear"></div>


    </div>
</div>
    <?php get_sidebar(); ?>
 </div></div>

<?php

  get_footer();


?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
KazeZlat, 2018-05-02
@KazeZlat

A difficult question is when Google did not help. And this is where it helps . In the WP_Query constructor, you need to pass a parameter posts_per_pagewith the number of posts per page or a parameter pagedwith the page number, which you need to get yourself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question