0

I'm trying to paginate a current category. But when I go to the next page, wordpress not show only all post of the current category, wordpress show all post of all categories. Somebody can help me?

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;

EDIT::::::::::

After do suggested changes (but don't works). Wordpress not limit 5 post per page and the paginator not appear.

<!-- 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 -->
Alexander Yancharuk
  • 13,817
  • 5
  • 55
  • 55

1 Answers1

0

You seem to have a left angle bracket < inside your query_posts function. Try removing that.

henrywright
  • 10,070
  • 23
  • 89
  • 150