php WP-PageNaviを使う时のコード
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php WP-PageNaviを使う时のコード相关的知识,希望对你有一定的参考价值。
$paged = get_query_var('paged')? get_query_var('paged') : 1; //pagedに渡す変数
$args = array(
'post_type' => 'program',
'posts_per_page' => 5, //posts_per_pageの指定
'paged' => $paged, //pagedの指定
);
$the_query = new WP_Query($args);
if ($the_query->have_posts()) :
while ($the_query->have_posts()) : $the_query->the_post();
// do something
endwhile;
endif;
//wp_pagenaviの記述
if(function_exists('wp_pagenavi')):
wp_pagenavi(array('query'=>$the_query)); ////wp_pagenavi()の呼び出し(ただし、引数の指定が必要!)
endif;
wp_reset_postdata();
以上是关于php WP-PageNaviを使う时のコード的主要内容,如果未能解决你的问题,请参考以下文章