Pagination is displayed but doesn't work

Hi,
I have set a loop with 4 posts. I have set pagination and it is displayed correctly. But when “next page” is clicked displayed posts remain the same. The page count does change though.

PG structure:

Hi @veras,
It is a little hard to troubleshoot from the information you have given. Can you give screenshots of your query post and post pagination actions, please?
Thanks,
Bob

Hello,

Thank you for looking!

This are screens:

Hm. I have moved whole section to new clean page … it works perfectly. Just have to find reason it doesn’t on previous page.
I have copied whole page and export it as new template. I created new page in WP and applied template. It works like that.
Is there any way to reset or clean whole PHP code from page with Pinegrow?

It looks like the problem appears whenever a page is set to “static home page” in WP. I replicated same problem with Oxygen builder.
Could be the WordPress bug?

I think you have found the origin of the problem.
Post pagination = for posts/pages, not for a document which is defined as static I guess, since it is not intended to offer pagination.

Hey @veras,
Sorry, I was having some WordPress installation difficulties yesterday. Apparently Local can get fussy when you are low on disk space!
First, I’m assuming this is the only loop on the page - Only the first loop called on a page can be paginated. If this is true then read on. If not, let me know - you can do a query swap and get it to work.

If the above ins’t true - I have been trying to figure out the most low-code way to do this in Pinegrow. In the newer versions of WordPress you have to changes up the $paged variable value in the query if it is a static page. The typical way to do it is an elseif loop. I think your best option would be to copy the existing php for the loop above and paste it into a custom php block.

  1. You can copy the code by clicking on the code symbol next to the trashcan at the top of the Show Posts - Smart title bar. Select all of the code except the include at the bottom.
  2. Add the PHP code into the div that currently has the loop.
  3. delete the loop action

Now for the code changes:
The current code should start with:

<?php
    $query1_args = array(
        'post_type' => 'post',
        'posts_per_page' => 4,
        'paged' => get_query_var( 'paged' ) ?: 1,
        'order' => 'ASC',
        'orderby' => 'date'
    )
?>
<?php $query1 = new WP_Query( $query1_args ); ?>

So - I’m not sure how much PHP you know. But…

  1. Before the first <?php...?> block you need to add in:
<?php 
if ( get_query_var( 'paged' ) ) { $paged = get_query_var( 'paged' ); }
elseif ( get_query_var( 'page' ) ) { $paged = get_query_var( 'page' ); }
else { $paged = 1; }
?>
  1. Within the first php block, change the 'paged' =>get_query_var('paged')?: 1, to 'paged => $paged,

I think that should be enough to get you going. The only thing that worries me is the include at the bottom. Those functions are probably included by some other aspect of your theme, but will cause a problem if not. Let me know.
Bob

I have tested the case and I confirm that in a standard situation, the smart action Post Pagination is running fine.

Standard situation = From a post index page template and/or an archive page template.

Note: I have also successfully tested with a custom post type and a custom query :slight_smile:

Thank you both for input! I will rearrange home page - it looks like I will have to learn more PHP before tackling situations like this.

1 Like