WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#3924 closed defect (bug) (fixed)

Page order specified on page writing screen is ignored by default

Reported by: johnbillion Owned by:
Milestone: 2.2 Priority: normal
Severity: minor Version: 2.2
Component: Template Keywords: has-patch
Focuses: Cc:

Description

By default, pages are listed in alphabetical order when wp_list_pages is used. The page order specified on the page writing screen is ignored unless it is explicitly set with the sort_column parameter within the template.

Steps to reproduce:

  1. Create two or more pages from Write > Write Page and specify a page order using the Page Order box on the right hand side. For example create a page named "Hello World" with page order 1 and a page named "A Boring Page" with page order 2.
  2. Visit your blog home page and note the page order of the list of pages in the sidebar is ignored and the pages are listed alphabetically.

I propose that wp_list_pages should instead sort first by menu_order and then by post_title (see attached patch). This means if no page order is specified, pages will still be sorted alphabetically which is more asthetically pleasing. However if a page order is specified (for one or more page) then it will take priority over the alphabetical sorting.

Example of a scenario:

Three pages are on your blog:

  1. The default "About" with no page order (defaults to 0).
  2. "Hello World" with no page order (defaults to 0).
  3. "A Boring Page" with page order of 1.

As it is now, these pages would be listed alphabetically, ignoring the wishes of "A Boring Page" to be listed at the bottom.

With my change to wp_list_pages "A Boring Page" will get listed at the bottom, as per the specified Page Order, but the rest of the pages will still be listed alphabetically. Which is nice.

Attachments (2)

3924.diff (603 bytes) - added by johnbillion 7 years ago.
Patch to allow Page Order to take priority over alphabetical listing of pages
3924.2.diff (639 bytes) - added by johnbillion 7 years ago.
Same as patch 3924 but with full path from root

Download all attachments as: .zip

Change History (5)

johnbillion7 years ago

Patch to allow Page Order to take priority over alphabetical listing of pages

comment:1 johnbillion7 years ago

  • Component changed from Administration to Template
  • Priority changed from low to normal
  • Severity changed from normal to minor

comment:2 foolswisdom7 years ago

  • Keywords has-patch added
  • Milestone changed from 2.3 to 2.2
  • Version set to 2.2

johnbillion7 years ago

Same as patch 3924 but with full path from root

comment:3 markjaquith7 years ago

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

(In [5049]) have wp_list_pages() default to menu_order sorting and only use post_title sorting as a secondary sort. props johnbillion. fixes #3924 for trunk.

Note: See TracTickets for help on using tickets.