1

I have been looking for a way to display a paginated loop on two pages. One works but the other doesn't.

On a category archive page (ex : http://riehling.mrcoolblog.com/projets/concevoir/ ) it works. Here is the archive.php code :

<!-- Header -->
<?php get_header();

if ( is_category() )
    echo '<div class="h1_row"><h1>' . single_cat_title('', false) . '</h1></div>';
else
    echo '<div class="h1_row"><h1><i class="fa fa-tag"></i>&nbsp;' . single_tag_title( '', false ) . '</h1></div>';
?>

<article class="content">

    <div class="loop center">

        <?php 
        if ( is_category() )
            echo category_description( );

        $paged = get_query_var('paged') ? get_query_var('paged') : 1; 

        $args = array(
                'posts_per_page'=>20,
                'cat' => $cat,
                'paged' => $paged
        );

        $loop = new WP_Query( $args );

        if ( have_posts() ) :
            while ( $loop->have_posts() ) : $loop->the_post();
                get_template_part('content');
            endwhile;
            get_template_part('pagination');
        endif; ?>
    </div>

</article>

</section>

<?php get_footer(); ?>

I also have a page called "page-projets.php" that is supposed to display exactly the same thing, except for all categories.

Here is the code :

<!-- Header -->
<?php get_header();?>

<div class="h1_row"><h1>Projets</h1></div>

<article class="content marg_art">

    <div class="loop center">

        <?php       
        $paged = get_query_var('paged') ? get_query_var('paged') : 1; 

        $args = array(
                'posts_per_page'=>20,
                'paged' => $paged
        );

        $loop = new WP_Query( $args );

        if ( have_posts() ) :
            while ( $loop->have_posts() ) : $loop->the_post();
                get_template_part('content');
            endwhile;
            get_template_part('pagination');
        endif; ?>
    </div>


</article>

<?php get_footer(); ?>

Here the pagination does not work.

Here are my permalink settings : https://s29.postimg.org/ydd0clllz/7065_10202014698902003_923697784_n.jpg

Thank you very much for your help !

Regards, Greg.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.