当前类别的分页


Pagination of current category

我正在尝试对当前类别进行分页。但当我转到下一页时,wordpress不会只显示当前类别的所有帖子,而是显示所有类别的所有文章。有人能帮我吗?

Category.php

<!-- loop -->
<?php $cat_ID = get_query_var('cat'); ?>
<?php query_posts('&cat=<' . $cat_ID . '&showposts=6'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="col-sm-12 col-md-6 col-xs-12 col-lg-4">
        <div class="thumbnail">
            <article>
                <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('photo-thumbnail') ?></a>
                <div class="caption">
                    <a href="<?php the_permalink(); ?>"><h3><?php the_title(); ?></h3></a>
                    <!-- añade custom field autor del relato -->
                </div>
            </article>
        </div>
        <div class="thumbnailFooter">
            <div class="pull-left" style="margin-bottom: 4px;">
                <?php echo get_avatar(get_the_author_meta('ID'), 32); ?>
            </div>
            <div class="smallFont pull-left" style="margin-left: 5px; width: 270px;">
                <span class="blue bold"><?php the_author(); ?></span>
            </div>
            <div class="verySmallFont pull-left" style="margin-left: 5px; margin-top: -3px;">
                en <?php the_category(none); ?> el <?php the_date(); ?>
            </div>
        </div>
    </div>
<?php endwhile; ?>
    <?php my_pagination(); ?>
<?php else : ?>
<?php endif; ?>
<!-- / fin del loop -->

Function.php

<?php
if (!function_exists('my_pagination')) :
    function my_pagination() {
        global $wp_query;
        $big = 999999999; // need an unlikely integer
        echo paginate_links(
            array(
                'base'      => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
                'format'    => '?paged=%#%',
                'current'   => max(1, get_query_var('paged')),
                'total'     => $wp_query->max_num_pages,
                'prev_text' => __('« Anterior'),
                'next_text' => __('Siguiente »'),
            )
        );
    }
endif;

编辑::::

之后进行建议的更改(但不起作用)。Wordpress不限制每页5篇文章,并且分页器不会出现。

<!-- loop de post -->
<?php
$project_category = wp_get_post_categories($post->ID); ?>
<?php $query = new WP_Query(array('posts_per_page' => 5)); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="col-sm-12 col-md-6 col-xs-12 col-lg-4">
        <div class="thumbnail">
            <article>
                <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('photo-thumbnail') ?></a>
                <div class="caption">
                    <a href="<?php the_permalink(); ?>">
                        <h3 style="font-weight:bold; margin-top: 0px; line-height: 1.3;"><?php the_title(); ?></h3>
                    </a>
                    <!-- añade custom field autor del relato -->
                </div>
            </article>
        </div>
        <div class="thumbnailFooter">
            <div class="pull-left" style="margin-bottom: 4px;">
                <?php echo get_avatar(get_the_author_meta('ID'), 32); ?>
            </div>
            <div class="smallFont pull-left" style="margin-left: 5px; width: 270px;">
                <span class="blue bold"><?php the_author(); ?></span>
            </div>
            <div class="verySmallFont pull-left" style="margin-left: 5px; margin-top: -3px;">
                en <span class="bold gray"><?php the_category(none); ?></span>
                el <?php the_date(); ?>
            </div>
        </div>
    </div>
<?php endwhile; ?>
    <div style="text-align: right; padding-right: 12px;">
        <?php my_pagination(); ?>
    </div>
<?php else : ?>
<?php endif; ?>
<!-- / fin del loop -->

您似乎有一个左尖括号<在query_posts函数中。尝试删除它。