web-dev-qa-db-fra.com

Pagination ne fonctionne pas sur la page Category.php

Mon site génère du code pour les anciens/nouveaux messages sur la page de catégorie, mais lorsque vous cliquez sur "ancien", le lien ne fonctionne pas. il génère/blog/page/2 à partir de/blog /

  1. Essayé quelques plugins (WPnavi, correctif de pagination de catégorie, et quelques autres qui étaient les premier et deuxième classés sous "recherche de pagination") mais cela n'a pas fonctionné

  2. J'ai essayé un tas des codes que j'ai trouvés sur wordpress.org

  3. Une seule catégorie de publication, pas une publication personnalisée.

Mais rien ne semble fonctionner ...

Voici le code

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>


<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

 <A href="<?php the_permalink() ?>" class="noborder"><?php if ( has_post_thumbnail() ) { the_post_thumbnail('thumbnail'); } ?></a></div>

<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?> "rel="bookmark"><?php the_title(); ?></a>
<section class="entry-content">
<?php $content = get_the_content();
      $content = strip_tags($content);
      echo substr($content, 0, 250);
?>... <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>" class="button">Full Post</a>

<?php endwhile; endif; ?>

</article>

<nav>
<div class="6u"><?php next_posts_link(sprintf( __( '%s', 'blankslate' ), '<span class="button">&larr;  Older Posts</span>' ) ) ?>
<div class="6u"><?php previous_posts_link(sprintf( __( '%s', 'blankslate' ), '<span class="button">&rarr; </span>' ) ) ?></div>
</nav>
1
Cdunn

Essayez ce code, pas très différent du vôtre, mais avec une imbrication correcte. Faites-moi savoir si cela fonctionne.

<?php if ( have_posts() ) :
    while ( have_posts() ) : the_post(); ?>

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

        <a href="<?php the_permalink() ?>" class="noborder"><?php if ( has_post_thumbnail() ) { the_post_thumbnail('thumbnail'); } ?></a>
        <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" rel="bookmark"><?php the_title(); ?></a>

            <section class="entry-content">
                <?php   $content = get_the_content();
                        $content = strip_tags($content);
                        echo substr($content, 0, 250) . '...';
                ?>
                <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>" class="button">Full Post</a>
            </section>

    </article>

    <?php endwhile; ?>
        <nav>
            <div class="6u"><?php next_posts_link(sprintf( __( '%s', 'blankslate' ), '<span class="button">&larr;  Older Posts</span>' ) ) ?>
            <div class="6u"><?php previous_posts_link(sprintf( __( '%s', 'blankslate' ), '<span class="button">&rarr; </span>' ) ) ?></div>
        </nav>          

<?php else : ?>

    <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>

<?php endif; ?>
2
Abhik

J'ai trouvé ceci pour résoudre mon problème, j'espère que cela aidera quelqu'un:

  add_action('init','yoursite_init');
function yoursite_init() {
  global $wp_rewrite;
        //add rewrite rule.
                add_rewrite_rule("author/([^/]+)/page/?([0-9]{1,})/?$",'index.php?author_name=$matches[1]&paged=$matches[2]','top');
                add_rewrite_rule("(.+?)/page/?([0-9]{1,})/?$",'index.php?category_name=$matches[1]&paged=$matches[2]','top');
                $wp_rewrite->flush_rules(false);
}
0
Cdunn