Pagination on custom loop

bruce3
72 Posts
bruce3 posted this 21 January 2017

Hi

I have tried to replace the default post layout on the 'default' template with a custom layout.

The code used is similar to the code below.

I have tried several settings to get the pagination to work but the same posts in the grid refreshes all the time. The pagination page numbers appear but the first page post list displays regardless of the settings.

When I remove the custom loops the pagination works again.

I have set the default post loop to only show on mobile devices so that it doesn't show on desktops but the pagination issue remains.

What is the correct way to implement the pagination with custom post loops?

<?php wp_query arguments $args ( 'post_type'?> array( 'post' ),
'post_status' => array( 'publish' ),
'cat' => '193',
// 'category_name' => 'possimus-aliquid-beatae-eos-odit',
// 'fields' => 'ids',
// Skip SQL_CALC_FOUND_ROWS for performance (no pagination).
'no_found_rows' => true, // counts posts, remove if pagination required
// 'nopaging' => false,
// 'paged' => '1',
'posts_per_page' => '4',
'ignore_sticky_posts' => false,
'no_found_rows' => true,
// 'offset' => '1',
'order' => 'DESC',
'orderby' => 'date',
'cache_results' => false,
'update_post_term_cache' => false, // grabs terms, remove if terms required (category, tag...)
'update_post_meta_cache' => false, // grabs post meta, remove if post meta required
);

// The Query
query_posts($args);

//Get the Posts
theme_blog_9();

// Restore original Post Data
wp_reset_postdata();
?>

Regards

Bruce

Hi I have tried to replace the default post layout on the 'default' template with a custom layout. The code used is similar to the code below. I have tried several settings to get the pagination to work but the same posts in the grid refreshes all the time. The pagination page numbers appear but the first page post list displays regardless of the settings. When I remove the custom loops the pagination works again. I have set the default post loop to only show on mobile devices so that it doesn't show on desktops but the pagination issue remains. What is the correct way to implement the pagination with custom post loops? &lt;?php wp_query arguments $args ( &#39;post_type&#39;?&gt; array( 'post' ), 'post_status' => array( 'publish' ), 'cat' => '193', // 'category_name' => 'possimus-aliquid-beatae-eos-odit', // 'fields' => 'ids', // Skip SQL_CALC_FOUND_ROWS for performance (no pagination). 'no_found_rows' => true, // counts posts, remove if pagination required // 'nopaging' => false, // 'paged' => '1', 'posts_per_page' => '4', 'ignore_sticky_posts' => false, 'no_found_rows' => true, // 'offset' => '1', 'order' => 'DESC', 'orderby' => 'date', 'cache_results' => false, 'update_post_term_cache' => false, // grabs terms, remove if terms required (category, tag...) 'update_post_meta_cache' => false, // grabs post meta, remove if post meta required ); // The Query query_posts($args); //Get the Posts theme_blog_9(); // Restore original Post Data wp_reset_postdata(); ?> Regards Bruce
Vote to pay developers attention to this features or issue.
1 Comments
Order By: Standard | Newest
Support Team
Support Team posted this 24 January 2017

Hello Bruce,
have you tested this code with default WP themes? Does it work as expected? In case it works with default theme properly then please provide access to your WP admin back end.
If the code fails with default WP theme then you'd better post the coding question on one of WP discussion boards.

regards,
Aileen

Hello Bruce, have you tested this code with default WP themes? Does it work as expected? In case it works with default theme properly then please provide access to your WP admin back end. If the code fails with default WP theme then you'd better post the coding question on one of WP discussion boards. regards, Aileen
You must log in or register to leave comments