我有一个名为“绘图”的自定义帖子类型,它具有三个类别。我在顶部(插图,绘画和草图)添加了一个类别导航,以按这些类别对帖子进行排序。如果我在一页上列出所有帖子,则效果很好,但如果将帖子限制为每页10个并添加分页,则排序无法正常工作。 有没有办法使它与分页一起工作?
这是暂存站点:http://www.wp-staging.pixelsandbeyond.io/drawings/
这是我的archive.php文件:
<div id="primary" class="content-area">
<main id="main" class="site__main">
<ul class="category-filters container list--unstyle">
<?php
$category = post_type_archive_title( '', false );
$parentCategory = get_cat_ID( $category );
if (!empty ($parentCategory) ) {
$cats = get_categories(
array(
'hide_empty' => 1,
'title_li' => '',
'child_of' => $parentCategory,
'posts_per_page' => 10,
'paged' => $paged
)
);
}
if (is_array($cats) || is_object($cats)) {
foreach($cats as $cat){
echo '<li class="category-filters__item"><span class="category-filters__name js-card-button" data-filter="category-' . $cat->slug . '">' . $cat->name . '</span></li>';
}
}?>
</ul>
<?php if ( have_posts() ) : ?>
<div class="grid grid--category js-modal">
<?php
global $wp_query;
$is_single_post = ($wp_query->post_count === 1);
?>
<article class="grid__item grid__item-header card js-card-button<?php if ($is_single_post): ?> card__header-single<?php endif; ?>" data-filter="js-card">
<header>
<h1 class="page-title"><?php echo post_type_archive_title( '', false ); ?></h1>
</header>
<?php $post_type = get_queried_object(); ?>
<a href="<?php echo esc_url( home_url( '/' ) ); ?><?php echo $post_type->rewrite['slug']; ?>" class="card__link"></a>
</article>
<?php while ( have_posts() ) : ?>
<?php the_post(); ?>
<?php get_template_part( 'template-parts/content', get_post_type() ); ?>
<?php endwhile; ?>
</div>
<div class="navigation--posts container">
<?php $args = array(
'prev_text' => __( '<' ),
'next_text' => __( '>' )
); ?>
<?php echo paginate_links( $args ); ?>
</div>
<?php else :
get_template_part( 'template-parts/content', 'none' );
endif;
?>
<?php get_template_part( 'global-templates/modal-work' ); ?>
</main><!-- #main -->
</div><!-- #primary -->
任何建议都将不胜感激!预先感谢!