Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WordPress Blog Pagination Not Working

I'm still stuck on this issue..

The pagination on my WordPress blog is not working - http://www.example.com/news

When you click a different page number it updates the URL (and page title) correctly but it does not show different posts.

Ive tried:

  • Disabling all plug-ins
  • Changing the permalink structure
  • Changing the number of blog posts displayed in Settings>Reading
  • Changing http://www.example.com/recall-news to a different path to avoid conflicting with a post category named "news"

Nothing has worked for me.

I've seen many solutions for a custom query, but I'm using the posts page that you set in Settings>Reading>Posts Page so I did not write any code to display the posts on this page.

  • What WordPress file do I modify to fix the blog pagination in this case? I'm guessing I can add something to functions.php, but I haven't found a solution yet.

UPDATE: I have not found the solution yet. I know I can do it by writing my own query but I want to stick with the default WP blog.

like image 474
cpcdev Avatar asked Sep 22 '15 14:09

cpcdev


People also ask

Why is pagination not working WordPress?

Look for improper code syntax if the code is there but pagination doesn't work. The line needs both the opening "lesser-than" sign (<), followed by a question mark. The code should close with a question mark, followed by a "greater-than" sign (>). If the code uses other variables, they should be well-formatted.

How do I get pagination page numbers in WordPress?

The easiest way to add numeric pagination in WordPress is by using the WP-PageNavi plugin. To use this plugin, you'll still need to make some changes to your theme's code, but it is a lot easier than the full code method because WP-PageNavi gives you complete control over your site's pagination.


2 Answers

I have played with the "posts pages" too but I'm getting no result.

Only working solution for me was a custome query in combination with the Page-Navi Plugin.

In my template i have the following code:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
        'post_type'         => 'post',
        'orderby'           => 'date',
        'order'             => 'DESC',
        'post_status'       => 'publish',
        'posts_per_page'    => 5,
        'paged'             => $paged,
    );
    $q = new WP_Query( $args );

    if ( $q->have_posts() ) {
        $displaylist = '<div class="list-group">';

        while ( $q->have_posts() ) {
            $q->the_post();

            // build up your entry

            unset( $displayTag );
        }

        $displaylist .= '</div>';

        echo( $displaylist );

        wp_pagenavi( array( 'query' => $q ) );

        wp_reset_postdata();
    }
?>

With the post_per_page i manage the entries per site. In while loop i build up the entries that should be showed.

like image 103
Manu Zi Avatar answered Oct 21 '22 04:10

Manu Zi


Check your WP loop in the category.php file (aka archive.php). It must contain the following:

if (have_posts()) : while (have_posts()) : the_post();

and finished with:

endwhile; endif;
like image 30
Kordaki Avatar answered Oct 21 '22 03:10

Kordaki