WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 5 years ago

#4531 closed enhancement (fixed)

Add limit parameter to get_pages

Reported by: DD32 Owned by: westi
Milestone: 2.8 Priority: normal
Severity: minor Version:
Component: Template Keywords: has-patch tested commit
Focuses: Cc:

Description

add 'numberposts' and 'offset' to get_pages() to allow for limiting of returned posts.

Attachments (3)

4531.get_pages-limits (914 bytes) - added by DD32 7 years ago.
Adds numberpages and offset to get_pages
4531-add-limit-parameters-to-get_pages.diff (846 bytes) - added by Speedboxer 7 years ago.
Add offset and number parameters to get_pages()
4531-number-offset-get_pages.diff (917 bytes) - added by Speedboxer 5 years ago.
Updated patch

Download all attachments as: .zip

Change History (18)

DD327 years ago

Adds numberpages and offset to get_pages

comment:1 DD327 years ago

'Doh!
Sorry, I meant "adds 'numberpages'" in the Description :)

comment:2 Speedboxer7 years ago

  • Component changed from Administration to Template
  • Keywords get_pages has-patch added

comment:3 Speedboxer7 years ago

  • Keywords changed from get_pages, has-patch to get_pages has-patch

comment:4 follow-up: rob1n7 years ago

Why is it 'numberposts'? Why not 'numberpages'?

comment:5 in reply to: ↑ 4 ; follow-up: foolswisdom7 years ago

Replying to rob1n:

Why is it 'numberposts'? Why not 'numberpages'?

DD32 commented on wp-hackers about that typo that is in the ticket, but not in the patch.

comment:6 ryan7 years ago

I think we use "number" in other places. Let's keep it consistent.

The number needs to be cast to an int for security. See how number is used in get_terms().

Speedboxer7 years ago

Add offset and number parameters to get_pages()

comment:7 Speedboxer7 years ago

  • Keywords needs-testing added

Patch 4531-add-limit-parameters-to-get_pages.diff adds offset and number parameters to get_pages().

comment:8 in reply to: ↑ 5 DD327 years ago

Replying to foolswisdom:

Replying to rob1n:

Why is it 'numberposts'? Why not 'numberpages'?

DD32 commented on wp-hackers about that typo that is in the ticket, but not in the patch.

See comment 1:

DD32:

'Doh! Sorry, I meant "adds 'numberpages'" in the Description :)

If we want to standarise on 'number' and 'offset' for all functions, then it might be an idea to depreciate "numberposts" in get_posts too:

function get_posts($args) {
	global $wpdb;

	$defaults = array(
		'numberposts' => 5, 'offset' => 0, 

comment:9 ryan7 years ago

  • Milestone changed from 2.3 to 2.4

comment:10 westi6 years ago

  • Milestone changed from 2.5 to 2.6
  • Owner changed from anonymous to westi
  • Status changed from new to assigned
  • Type changed from defect to enhancement

marking as an enhancement

moving to 2.6 for resolving.

Fix with #4711

comment:11 follow-up: Denis-de-Bernardy5 years ago

still current?

Speedboxer5 years ago

Updated patch

comment:12 in reply to: ↑ 11 Speedboxer5 years ago

Replying to Denis-de-Bernardy:

still current?

It probably is, updated my patch.

comment:13 Denis-de-Bernardy5 years ago

  • Keywords tested commit added; get_pages needs-testing removed
  • Milestone changed from 2.9 to 2.8

patch is harmless

comment:14 Denis-de-Bernardy5 years ago

I *am* wondering how this is useful, though. :D

comment:15 westi5 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In [11251] - Add paging support to get_pages(). Fixes #4531 props DD32.

Note: See TracTickets for help on using tickets.