Wordpress custom wp_pagenavi无法在具有自定义查询的自定义页面上工作

Wordpress custom wp_pagenavi无法在具有自定义查询的自定义页面上工作,wordpress,navigation,Wordpress,Navigation,我正在尝试做一些自定义页面,我没有使用wp_pagenavi插件,而是对我的自定义页面使用一个自定义函数,现在它只在index.php页面上工作,但几天前在我添加更多查询元素之前它工作得很好 //custom pagepavi function function my_pagenavi( $the_query = false ){ global $wp_query; $query = ($the_query) ? $the_query : $wp_query; $max = $que

我正在尝试做一些自定义页面,我没有使用wp_pagenavi插件,而是对我的自定义页面使用一个自定义函数,现在它只在index.php页面上工作,但几天前在我添加更多查询元素之前它工作得很好

//custom pagepavi function
function my_pagenavi( $the_query = false ){
  global $wp_query;
  $query = ($the_query) ? $the_query : $wp_query;
  $max = $query->max_num_pages;
  $current_page = max(1, get_query_var('paged')); 
  $big = 999999999; 
  if ( $max > 1 ) { 
        echo "<div class='pagination' style='height:auto'>";
        echo paginate_links(array(
              'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),  
              'format' => '?paged=%#%',
              'current' => $current_page,
              'show_all'     => false,
              'total' => $max, 
              'type' => 'list',
              'prev_text' => __('PREV','dnp_theme'),
              'next_text' => __('NEXT','dnp_theme'), 
        ));  
        echo "</div>";
  }
//自定义pagepavi函数
函数my_pagenavi(_query=false){
全局$wp_查询;
$query=($theu查询)?$theu查询:$wp\u查询;
$max=$query->max\u num\u页面;
$current_page=max(1,get_query_var('paged');
$big=99999999;
如果($max>1){
回声“;
回显分页链接(数组(
'base'=>str_replace($big,%#%',esc_url(get_pagenum_link($big)),
'格式'=>'?分页=%#%',
“当前”=>$current\u页面,
“全部显示”=>false,
“总计”=>$max,
'类型'=>'列表',
“prev_text'=>uuu('prev','dnp_主题”),
“下一个文本”=>“‘下一个’,‘dnp_主题’”,
));  
回声“;
}
}

下面是我的模板页面中的循环

  //some query stuff
  $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  $query = 'offset=0&paged='.$paged;

  $blogs = new WP_Query($query);

  if ( $blogs->have_posts() ) : ?>              

        <?php /* Start the Loop */ ?>

        <?php while ( $blogs->have_posts() ) : $blogs->the_post(); ?>
              <?php get_template_part( 'content', get_post_format() ); ?>
        <?php endwhile; ?>

        <?php my_pagenavi( array('query' => $blogs) ); ?>
  <?php endif; ?>
//一些查询内容
$paged=(获取查询变量('paged'))?获取查询变量('paged'):1;
$query='offset=0&paged='。$paged;
$blogs=新的WP_查询($Query);
如果($blogs->have_posts()):?>

为什么不加载任何内容?结束后发生了什么事,请编写此代码

全局$wp_查询

$big=99999999;//需要一个不太可能的整数

回显分页链接(数组(


))

查询不正确,这就是它不工作的原因,至少它不工作,我让它工作正常:)

而不是

$blogs = new WP_Query($query);
所有这些都应该是

$blogs = query_posts( 'post_type=post&posts_per_page=4&paged='.get_query_var('paged') );
该循环与其他循环一样,工作完美

  if ( have_posts() ) : ?>              

        <?php /* Start the Loop */ ?>

        <?php while ( have_posts() ) : the_post(); ?>
              <?php get_template_part( 'content', get_post_format() ); ?>
        <?php endwhile; ?>

        <?php my_pagenavi(); ?>
  <?php endif; ?>
if(have_posts()):?>
  if ( have_posts() ) : ?>              

        <?php /* Start the Loop */ ?>

        <?php while ( have_posts() ) : the_post(); ?>
              <?php get_template_part( 'content', get_post_format() ); ?>
        <?php endwhile; ?>

        <?php my_pagenavi(); ?>
  <?php endif; ?>