WordPress自定义帖子类型分页 [英] Wordpress custom post type pagination
本文介绍了WordPress自定义帖子类型分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用wp pagenavi
插件和WordPress中的自定义帖子类型(作品集页面)进行分页,但我没有运气.
I am trying to get pagination working with the wp pagenavi
plugin and a custom post type (portfolio page) in WordPress and I am having no luck.
这是我的投资组合页面的精简版:
Here is a stripped down version of my portfolio page:
<?php get_header(); ?>
<?php
$type = 'portfolio';
$args=array(
'post_type' => $type,
'post_status' => 'publish',
'paged' => $paged,
'posts_per_page' => 1,
'caller_get_posts'=> 1
);
$temp = $wp_query; // assign original query to temp variable for later use
$wp_query = null;
$wp_query = new WP_Query($args);
?>
<?php if($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post(); ?>
...
<?php endwhile; else : ?>
...
<?php endif; ?>
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
$wp_query = null; $wp_query = $temp; ?>
<?php get_footer(); ?>
我的永久链接设置为:
/%postname%/
,我重新保存了它们.
and I have re-saved them.
当我进入到投资组合的第二页时,我得到了404页.知道为什么会这样吗?
When I got to page two of my portfolio, I get a 404 page. Any idea why this is happening?
感谢您的帮助.
推荐答案
我认为您在旧WordPress URL重定向方面遇到了不好的情况.
I think you are having a bad case of the old WordPress URL redirect.
尝试添加此过滤器以使其停止:
Try adding this filter to stop it:
add_filter('redirect_canonical','my_disable_redirect_canonical');
function my_disable_redirect_canonical( $redirect_url ) {
if ( is_single( 'portfolio' ) )
$redirect_url = false;
return $redirect_url;
}
这篇关于WordPress自定义帖子类型分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文