New answers tagged

-1

You need to add your query variable to the global used on the function, in that case "$wp_query", just like that: <?php $yourQuery_args = ['posts_per_page' => '7',]; $yourQuery = new WP_Query( $yourQuery_args ); $wp_query = $yourQuery; get_template_part('pagination'); ?>


0

The solution: The problem is $loop variable is not in global scope. So you need to add it to global in you blogslist.php file by adding global $loop; before $loop = new WP_Query($args); line. More Efficient Way: Alternatively, you can also pass $loop as an argument like this: function wpbeginner_numeric_posts_nav($loop) { // Codes here.. you also need to ...


0

i know that but i want to add when on the first page that is maxed like 20 posts anyone can press like N.2 to go to the second page that will be olders posts like this


0

I don't know about the shortcode above but in regular WordPress, you can control the number of posts on your blog page under Settings > Reading.


0

In my case, using Divi and the PageNavi plugin, the reason I was getting the 404 was that the page template (archive in my case) was getting the paged query parameter using get_query_var( 'paged' ), instead all I had to do was use the global variable like below: <?php /* Template Name: Archives */ get_header(); ?> <?php // $paged is a global ...


0

After an exhausted effort of a whole day finally find the solution. i write these two functions in my functions.php file and finally i got the expected result. function remove_page_from_query_string($query_string) { if ($query_string['name'] == 'page' && isset($query_string['page'])) { unset($query_string['name']); // 'page'...


0

I added below code in functions.php and it is working fine now. function custom_query( $query ){ if(is_category()){ $query->set( 'post_type', array( 'math' ) ); $query->set( 'posts_per_page', '2' ); } } add_action('pre_get_posts', 'custom_query'); Thank you all for your suggestions.


0

$wp_query dump on page 1 (http://archive.local/category/mathematics/average) WP_Query Object ( [query] => Array ( [category_name] => mathematics/average ) [query_vars] => Array ( [category_name] => average [error] => [m] => [p] => 0 [post_parent] => [subpost] => [subpost_id] => [attachment] => [attachment_id] => 0 [name] => [static] => [pagename] => [...


0

This's the plugin you're looking for: https://wordpress.org/plugins/ajax-load-more/ Load more posts, pages and comments using AJAX.


2

To get the canonical (not ?page=1) reference URL to start the pagination from you have to change 'base' => '%_%' to 'base' => get_pagenum_link() . '%_%' // get_pagenum_link() default is '1' which will give you the first page of paginated posts and %_% will be replaced by 'format' parameter on the next pages.


0

It looks like $current_page can be a minimum of 1. in the WP Codex the default is 0. If you change $current_page = max(1, get_query_var('paged')); to $current_page = max(0, get_query_var('paged')); you may get it to work how you want it to work. If this is the solution (or part of it), you may also have to adjust your logic elsewhere to make 0 the first page ...


0

This guy shows how to create AJAX pagination... https://artisansweb.net/load-wordpress-post-ajax/ Very easy to follow, effective results.


0

Remove all your pagination and try something like this, where mytheme is the name of your theme <?php $GLOBALS['wp_query']->max_num_pages = $custom_query->max_num_pages; the_posts_pagination(array( 'next_text' => '<span class="meta-nav" aria-hidden="true">' . __('Next Post', 'mytheme') . '</span> ' . '<span class="screen-...


0

You should use the pre_get_posts action to get the correct number of category pages and links. The complete solution is explained here.


2

This is another example of what is by far the most common mistake I've seen in WordPress development. I don't think it's even close to whatever the next most common is. I'm very curious as to what documentation or tutorials are out there that are teaching this approach to queries, or what could be done to the official documentation to make this clearer. The ...


0

Here is the snippet for archive navigation with previous and next link along with the select dopwdown. Select will contain the list of all pages and page url as value of option. onChange is used to redirect page when select option is changed. You can use following code and modify as per your need. function wpso_custom_archive_navigation() { global $...


Top 50 recent answers are included