WordPress.org

Make WordPress Core

Opened 9 years ago

Closed 7 years ago

#2959 closed defect (bug) (fixed)

wp_list_pages does not add current_page_item class on page_for_posts

Reported by: skeltoac Owned by: mdawaffe
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.7
Component: Template Keywords: has-patch
Focuses: Cc:

Description

Menus that rely on wp_list_pages are broken when page_for_posts is accessed.

Attachments (2)

posts-page.diff (1.6 KB) - added by skeltoac 9 years ago.
2959.diff (508 bytes) - added by mdawaffe 7 years ago.

Download all attachments as: .zip

Change History (21)

@skeltoac9 years ago

comment:1 @skeltoac9 years ago

  • Keywords has-patch 2nd-opinion added
  • Owner changed from anonymous to skeltoac
  • Status changed from new to assigned

Attached patch introducing $wp_query->is_posts_page and modifying $wp_query->get_queried_object().

comment:2 @ryan9 years ago

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

(In [4023]) Fix current page handling when using page_for_posts. Props skeltoac. fixes #2959

comment:3 @francesconegri8 years ago

  • Milestone changed from 2.1 to 2.1.2
  • Resolution fixed deleted
  • Status changed from closed to reopened

current_page_item is again _not set_ on page_for_posts in 2.1.1
(it worked in 2.1)

comment:4 @jhodgdon8 years ago

See also #3910 - a duplicate of this bug.

So I finally understand how to reproduce the bug (and agree it is a bug):

a) Make a few pages in WordPress

b) On the Options / Reading page, choose one of your pages to be the "posts page", and update.

c) Make sure wp_list_pages is in the blog sidebar for your theme.

d) Visit the blog page. Click on the page that you chose as the "posts page", and you will see posts, but the CSS class for the LI in the posts list on the right is not set to be "current_page_item". Click on a different page, and when that page is displayed, the LI class is set to "current_page_item".

Is that right? I'll test the patch above.

comment:5 follow-up: @jhodgdon8 years ago

Apparently, [4956] took the changes from [4023] back out, to fix #3885 ... thereby reopening this bug instead.

comment:6 @ryan8 years ago

  • Owner changed from skeltoac to ryan
  • Status changed from reopened to new

comment:7 in reply to: ↑ 5 @dwzemens8 years ago

Replying to jhodgdon:

Apparently, [4956] took the changes from [4023] back out, to fix #3885 ... thereby reopening this bug instead.

jhodgdon: You have described how to duplicate the problem exactly. That is the issue. It worked correctly in 2.1, but not in 2.1.1 --- thanks for taking steps to resolve it.

comment:8 @redbrandonk8 years ago

  • Cc redbrandonk added

comment:9 @foolswisdom8 years ago

  • Milestone changed from 2.1.4 to 2.2

comment:10 @Nazgul8 years ago

  • Keywords needs-patch added; has-patch 2nd-opinion removed

comment:11 @ryan8 years ago

  • Milestone changed from 2.2 to 2.3

comment:12 @ariejan8 years ago

  • Owner changed from ryan to ariejan
  • Status changed from new to assigned

Ping

Does anyone know why this bug hasn't been fixed yet? Are there any problems in particular that prevent this bug from being fixed?

comment:13 @lloydbudd8 years ago

ariejan, "needs-patch"

comment:14 @betsyk7 years ago

Hi there. Just wanted to add more info about this bug. Many users have reported and discussed it in the WP forums at: http://wordpress.org/support/topic/107583. I have outlined the troubleshooting steps required to replicate & resolve the problem on my blog at: http://www.umaitech.com/cms/?p=27.

comment:15 @mdawaffe7 years ago

  • Owner changed from ariejan to mdawaffe
  • Status changed from assigned to new

comment:16 @mdawaffe7 years ago

  • Keywords has-patch added; needs-patch removed
  • Status changed from new to assigned

[4956] and [4023] are unrelated. The regression was caused by [4863] [4864] fixing #3049.

Attached gives the current_page_item class to the page_for_posts page and does not cause a #3049 regression.

@mdawaffe7 years ago

comment:17 @ryan7 years ago

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

(In [7073]) Add current_page_item on page_for_posts. Props mdawaffe. fixes #2959

comment:18 @sivel7 years ago

  • Cc redbrandonk removed
  • Milestone changed from 2.5 to 2.8
  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Version changed from 2.1 to 2.7

This fix only gives the current_page_item class to the blog page when you are on the blog page. The blog page is no longer given current_page_item once you click on one of the posts. This is something that I have seen many users complaining about.

Perhaps we should give the blog page current_page_parent and maybe even current_page_ancestor when on a single post?

comment:19 @sivel7 years ago

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

Apologies. It looks like this is already functioning as I had described.

Note: See TracTickets for help on using tickets.