自定义文章类型和taxonomy分类分页404错误解决方法

核心提示:做wordpress C-Technology 主题下载模块时用到自定义文章类型taxonomy,做的时候taxonomy分类分页出现404错误,查了好多方法从老外的网站找到了问题https://stackoverflow.com/questions/...

做wordpress C-Technology 主题下载模块时用到自定义文章类型taxonomy,做的时候taxonomy分类分页出现404错误,查了好多方法从老外的网站找到了问题https://stackoverflow.com/questions/8269713/custom-post-type-and-taxonomy-pagination-404-error,注册register_post_type的时候,要有如下的参数:

'exclude_from_search' =>false,

前台调用:

<?php
global $paged,$page,$wp_query;
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} elseif ( get_query_var('page') ) {
// applies when this page template is used as a static homepage in WP3+
$paged = get_query_var('page');
} else {
$paged = 1;
}

$download_category_slug="";
$term_vip = get_term_by('name', single_term_title("",false), 'downloadcat');
$download_category_slug = $term_vip -> slug;
$term = get_queried_object();
$args = array(
'post_type' => 'download',
'downloadcat' =>$download_category_slug,
'paged'=>$paged,
'post_status' => 'publish',

);
//query_posts( $args );
//if ( have_posts() ) :
$wp_query->query($args); //var_dump($wp_query);
if($wp_query->have_posts()):
?>
<ul class="list_download">
<?php //while (have_posts()) : the_post();
while ($wp_query->have_posts()) : $wp_query->the_post();
$filename = get_meta_option('wpmby_filename');
?>
<li class="clearfix"><a href="<?php echo stripslashes($filename); ?>" target="_blank" title="点击下载:<?php the_title(); ?>"><?php the_title(); ?></a><a href="<?php echo stripslashes($filename); ?>" target="_blank" title="点击下载:<?php the_title(); ?>"><span class="dbtn"><i class="glyphicon glyphicon-download-alt" aria-hidden="true"></i> &nbsp;立即下载</span> </a></li>
<?php endwhile;?>
</ul>
<style>
</style>
<?php else : ?>
<?php get_template_part( 'template-parts/content', 'none' ); ?>
<?php endif; ?>

问题解决了

在线客服