第2页的“自定义分类分页显示404” >> [

问题描述 投票:0回答:1
我在我的网站上添加了分页代码(https://www.wpblog.com/use-wp_query-to-create-pagination/)。此代码在我的页面模板中效果很好。但是,当我在自定义分类模板中执行相同的编码时,它无法从页面2开始工作。它将转到错误页面。请帮助。

此处为taxonomy-somename.php的代码

<?php /** * The template for displaying archive pages. * * Learn more: http://codex.wordpress.org/Template_Hierarchy * * @package Sydney */ get_header(); ?> <div id="primary" class="content-area col-md-9"> <main id="main" class="post-wrap" role="main"> <ul id="service-list"> <?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $paged = (get_query_var( 'page' )) ? get_query_var( 'page' ) : 1; $aud_query = new WP_Query( array( 'post_type' => 'attachment', 'post_status' => 'inherit', //'post_mime_type' => 'image', 'post_mime_type' => 'audio', 'posts_per_page' => 2, 'paged' => $paged, 'post_parent__in' => $query->posts, 'order' => 'DESC', 'tax_query' => array( array( 'taxonomy' => 'mymusic', 'field' => 'slug', 'terms' => $term->slug, ), ), ) ); ?> <!----start--------> <?php if( $aud_query->have_posts() ) : ?> <?php while($aud_query->have_posts()) : $aud_query->the_post(); ?> <?php echo get_the_title($attach_id); echo '<br>'; ?> <?php endwhile ?> <?php if (function_exists("pagination")) { pagination($aud_query->max_num_pages); } ?> <?php else :?> <h3><?php _e('404 Error: Not Found', ''); ?></h3> <?php endif; wp_reset_postdata();?> </ul><!-- #service-list --> </main><!-- #main --> </div><!-- #primary --> <?php get_footer(); ?>

我已在我的网站上添加了分页代码(https://www.wpblog.com/use-wp_query-to-create-pagination/)。此代码在我的页面模板中效果很好。但是,当我在自定义分类法中执行相同的编码时...
php wordpress pagination custom-taxonomy
1个回答
1
投票
通过此链接Wordpress - Custom Taxonomy Pagination找到了自己的解决方案将此代码添加到functions.php中并重新生成永久链接。
© www.soinside.com 2019 - 2024. All rights reserved.