WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 3 months ago

#39447 reviewing enhancement

Improvement to the get_the_posts_navigation

Reported by: thirumani02 Owned by: SergeyBiryukov
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Query Keywords: needs-testing needs-patch needs-unit-tests
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 (4)

39447.diff (3.9 KB) - added by Howdy_McGee 16 months ago.
Additional max_num_pages args
39447-2.diff (2.3 KB) - added by Howdy_McGee 7 months ago.
Revised and linted.
39447.3.diff (2.4 KB) - added by garrett-eclipse 6 months ago.
Minor Refresh
39447.4.diff (4.8 KB) - added by Howdy_McGee 7 weeks ago.
New $total argument for get_the_posts_pagination( $args )

Download all attachments as: .zip

Change History (16)

@Howdy_McGee
16 months ago

Additional max_num_pages args

#1 @Howdy_McGee
16 months 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.

This ticket was mentioned in Slack in #core by howdy_mcgee. View the logs.


13 months ago

#3 @SergeyBiryukov
13 months ago

  • Milestone changed from Awaiting Review to 5.5
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing
  • Summary changed from Improvment to the get_the_posts_navigation to Improvement to the get_the_posts_navigation

#4 @SergeyBiryukov
10 months ago

  • Milestone changed from 5.5 to 5.6

This ticket was mentioned in Slack in #core by hellofromtonya. View the logs.


7 months ago

#6 @davidbaumwald
7 months ago

  • Keywords needs-refresh added

@Howdy_McGee Can you refresh this patch against the /src/ dir in trunk? There are also a couple WPCS issues to resolve as well.

@Howdy_McGee
7 months ago

Revised and linted.

@garrett-eclipse
6 months ago

Minor Refresh

#7 @garrett-eclipse
6 months ago

  • Keywords needs-refresh removed

The patch is looking great @Howdy_McGee dropping the refresh label. In 39447.3.diff the only change I made was to add a missing period to the first new docblock sentence and recreate the patch from the root of the repo so it applies cleanly.

#8 @SergeyBiryukov
6 months ago

  • Milestone changed from 5.6 to 5.7

It seems like get_the_posts_pagination() would benefit from a similar change for consistency.

Adding a unit test might also be a good idea. Moving to the next release for now.

This ticket was mentioned in Slack in #core by lukecarbis. View the logs.


3 months ago

#10 @noisysocks
3 months ago

  • Keywords needs-patch needs-unit-tests added; has-patch removed

Hi @Howdy_McGee @Garrett-eclipse, are you still able to work on this for 5.7?

Adding needs-patch and needs-unit-tests to reflect the changes requested above.

Last edited 3 months ago by noisysocks (previous) (diff)

This ticket was mentioned in Slack in #core by lukecarbis. View the logs.


3 months ago

#12 @audrasjb
3 months ago

  • Milestone changed from 5.7 to Future Release

As per today's bug scrub, let's move this ticket to Future release so it can be handled in time for WP 5.8. If we have a patch and unit tests in time for 5.7 beta 1, please feel free to move it back to milestone 5.7.

@Howdy_McGee
7 weeks ago

New $total argument for get_the_posts_pagination( $args )

Note: See TracTickets for help on using tickets.