0

I am currently testing the pagination of my website, which does not work...

If you look at an archive page, you can see that when the limit is there (i set it to two posts, for my tests), the pagination bit is displayed : http://riehling.mrcoolblog.com/projets/concevoir/

(I use the wp-pagination plug-in).

But, on the second page, I end up with a 404 : http://riehling.mrcoolblog.com/projets/concevoir/page/2/

How is that possible ?

Here is my archive.php :

<article>
    <?php if ( is_category() ){
        echo '<h1>' . single_cat_title('', false) . '</h1>';

        echo category_description( );

    }
    else{
        echo '<h1><i class="fa fa-tag"></i>&nbsp;' . single_tag_title( '', false ) . '</h1>';
    }


    if ( have_posts() ) : ?>
    <div class="loop center">
        <?php while ( have_posts() ): the_post();
            get_template_part('content');
        endwhile; ?>
    </div>

    <?php get_template_part('pagination');
endif; ?>

Here is my permalink structure : Domain + /projets/%category%/%postname%/

Thank you for your help.

0

Here is my code :

<?php get_header();?>

<?php display_breadcrumbs(); ?>

<article>
    <?php if ( is_category() ){
        echo '<h1>' . single_cat_title('', false) . '</h1>';
        echo category_description( );
    }
    else
        echo '<h1><i class="fa fa-tag"></i>&nbsp;' . single_tag_title( '', false ) . '</h1>';
    ?>

    <div class="loop center">
        <?php
        $paged = get_query_var('paged') ? get_query_var('paged') : 1; 

        $args = array(
            'post_type' => 'post',  //Specyfying post type  
            'paged' => $paged       //For pagination
        );

        $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 
if( is_category() ){?>
    <div id="dls" class="row">
        <div  class="center">
            <?php
            // Dossier de presse
            $dossier = get_post_meta($post->ID, 'dossier', true); 
            if( !empty( $dossier ) )
                $dossier = ' pdf="' . $dossier . '"';
            echo do_shortcode( '[dossier' . $dossier . ']' );
            ?>      
        </div>
    </div>
    <?php
    echo '
    <div id="form" class="row metaform">
        <h2 class="center">Vous souhaitez réaliser un projet similaire&nbsp;?</h2>';
        // echo '<p>/projets/' . get_the_category()[0]->slug . '</p>';
        contact_form( '/projets/' . get_the_category()[0]->slug );
    echo '</div>';
}
?>

<?php get_footer(); ?>

And the pagination.php file :

<nav class="pagination group">
    <?php if ( function_exists('wp_pagenavi') ): ?>
        <?php wp_pagenavi(); ?>
    <?php else: ?>
        <ul class="group">
            <li class="prev left"><?php previous_posts_link(); ?></li>
            <li class="next right"><?php next_posts_link(); ?></li>
        </ul>
    <?php endif; ?>
</nav>

This link does not work : riehling.mrcoolblog. com/projets/concevoir/

But this one does : riehling.mrcoolblog. com/concevoir/page/2/

So does this one : riehling.mrcoolblog. com/concevoir/

I guess there is something wrong with my permalink structure, but I don't know what it is...

In Yoast, I removed the category base and I added it in the "permalink" settings (as described in the first post), maybe I should remove that and use another way ? What is the clean way to put '/projets/' in front of any archive/post ?

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.