WordPress.org

Make WordPress Core

Opened 11 years ago

Closed 8 years ago

#10745 closed defect (bug) (duplicate)

Add number parameter to wp_list_pages()

Reported by: security_man Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.8.4
Component: Template Keywords:
Focuses: Cc:

Description

well, it does and it doesnt... if you put in 5 you get none, if you put in 7 you get 10, if you put in 14 you get 8... not sure if there is a pattern but thats what is happening

Change History (7)

#1 @security_man
11 years ago

this is the call i am using to get the 8 outputs

<?php wp_list_pages("child_of=5&title_li=&depth=1&sort_column=menu_order&number=14"); ?>

#2 @scribu
11 years ago

  • Keywords needs-patch added; wp_list_pages sql limit removed
  • Milestone changed from Unassigned to 2.9
  • Summary changed from number paramter doesnt work with wp_list_pages to Add number parameter to wp_list_pages()
  • Type changed from defect (bug) to enhancement

That's because wp_list_pages() doesn't have a 'number' parameter.

#3 @janeforshort
11 years ago

  • Milestone changed from 2.9 to Future Release

Punting due to feature freeze.

#4 @topcat123
10 years ago

  • Type changed from enhancement to defect (bug)

The codex claims this feature is already implemented:

http://codex.wordpress.org/Function_Reference/wp_list_pages#Parameters

However, the SQL LIMIT argument passed into get_pages() from wp_list-pages() is limiting the results before the filters are applied.

See line 3181 onwards in post.php:

http://core.trac.wordpress.org/browser/trunk/wp-includes/post.php

I suggest the LIMIT is abandoned and instead a manual restriction on qty of results returned is implemented at the end of the get_pages() function.

#5 follow-up: @wonderboymusic
8 years ago

  • Keywords needs-patch removed
  • Resolution set to invalid
  • Status changed from new to closed

This works now in trunk - pick a page with more than 2 children by id and run this:

php -r 'require( "wp-load.php" ); wp_list_pages("child_of=47&title_li=&number=2");'

#6 in reply to: ↑ 5 @SergeyBiryukov
8 years ago

  • Component changed from General to Template
  • Resolution invalid deleted
  • Status changed from closed to reopened

Replying to wonderboymusic:

This works now in trunk

It doesn't for me. In get_pages(), LIMIT is applied earlier than children are calculated:
http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/post.php#L3542

#7 @SergeyBiryukov
8 years ago

  • Milestone Future Release deleted
  • Resolution set to duplicate
  • Status changed from reopened to closed

This is, however, a duplicate of #10230.

Note: See TracTickets for help on using tickets.