WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 7 weeks ago

#39447 new enhancement

Improvment to the get_the_posts_navigation

Reported by: thirumani02 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Query Keywords: has-patch needs-testing
Focuses: Cc:

Description

https://core.trac.wordpress.org/browser/tags/4.7/src/wp-includes/link-template.php Here at get_the_posts_navigation the function check global wp query(Globals['wp_query'\]) for displaying markup. But in many cases we may need to display the navigation for custom wp query which has unique query options(max_num_page, post_per_page). So it would be great, if we can check the our custom query's max_num_page.

Hope it make sense.

Thank you

Attachments (1)

39447.diff (3.9 KB) - added by Howdy_McGee 7 weeks ago.
Additional max_num_pages args

Download all attachments as: .zip

Change History (2)

@Howdy_McGee
7 weeks ago

Additional max_num_pages args

#1 @Howdy_McGee
7 weeks ago

  • Keywords has-patch needs-testing added

This patch adds additional $args to the get_the_posts_navigation() and get_the_posts_pagination() functions to handle max_num_pages. Instead of defaulting to the global $wp_query->max_num_pages you can pass a defined integer:

get_the_posts_navigation( array( 'max_num_pages' => 3 ) );
get_the_posts_pagination( array( 'max_num_pages' => 3 ) );

I've tested this patch with a custom query and the default posts.

Note: See TracTickets for help on using tickets.