2017-11-20 11 views
-1

iは、ワードプレスでpage.phpにページネーション作品を作ったことができません。ページネーション - WP

あなたがpost_type属性にここにあなたのカスタムタイプ名を定義することができ、どのように行うコーデックスのsplainで

global $query_string; 
$ourCurrentPage = get_query_var('paged'); 
$post = array(
    'post_per_page' => 10, 
    'paged' => $ourCurrentPage 
); 

$search_query = wp_parse_str($query_string ,$post); 
$search = new WP_Query($search_query); 
if ($search -> have_posts()) { 
    while ($search -> have_posts()) { 
    $search -> the_post(); 
    ... 
    ... 
    //rest of loop 

が、それは

答えて

0

このコードを試してみてください作品作ることができない。ここにコードがありますページ区切りでリストポストを取得することができます。

<?php 
 
\t \t $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
 

 
     $args = array(
 
      'post_type' => 'page', 
 
      'orderby' => 'title', 
 
      'order' => 'ASC', 
 
      'posts_per_page' => 2, 
 
      'paged' => $paged 
 
     ); 
 

 
     $the_query = new WP_Query($args); 
 

 
    ?> 
 

 
    <?php if($the_query->have_posts()) : ?> 
 

 
    <!-- options --> 
 
    <div class="col-md-12 options border-bottom"> 
 

 
     <!-- pagination --> 
 
     <ul class="pagination pull-right"> 
 
      <li><?php echo get_next_posts_link('Next Page', $the_query->max_num_pages); ?></li> 
 
      <li><?php echo get_previous_posts_link('Previous Page'); ?></li> 
 
     </ul> 
 

 
    </div> 
 
    <!-- /.options --> 
 

 
    <!-- cemeteries --> 
 
    <div class="cemeteries"> 
 

 
     <?php while($the_query->have_posts()) : $the_query->the_post(); ?> 
 

 
      <!-- pages --> 
 
      <div class="col-md-12"> 
 

 
       <div class="col-md-4"> 
 
        <?php 
 
         if (has_post_thumbnail()) { 
 
          the_post_thumbnail('', array('class' => 'img-responsive')); 
 
         } 
 
        ?> 
 
       </div> 
 

 
       <div class="col-md-8"> 
 
        <h2><?php the_title(); ?></h2> 
 
        <?php the_content(); ?> 
 
        <p><a href="<?php the_permalink(); ?>"><button>Visit pages</button></a></p> 
 
       </div> 
 

 
      </div> 
 
      <!-- /.pages --> 
 

 
     <?php endwhile; ?> 
 

 
    </div> 
 
    <!-- /.cemetries --> 
 

 
    <!-- options --> 
 
    <div class="col-md-12 options border-bottom"> 
 

 
     <!-- pagination --> 
 
     <ul class="pagination pull-right"> 
 
      <li><?php echo get_next_posts_link('Next Page', $the_query->max_num_pages); ?></li> 
 
      <li><?php echo get_previous_posts_link('Previous Page'); ?></li> 
 
     </ul> 
 

 
    </div> 
 
    <!-- /.options --> 
 

 
    <?php wp_reset_postdata(); ?> 
 

 
    <?php else: ?> 
 

 
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p> 
 

 
    <?php endif; ?>

私はあなた

+1

おかげでたくさんして、Priyankaのために、このコードは役に立ち願っています!このコードは完全に機能します! :) –