Ticket #2959 (closed defect (bug): fixed)

Opened 6 years ago

Last modified 3 years ago

wp_list_pages does not add current_page_item class on page_for_posts

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

Description

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

Attachments

posts-page.diff Download (1.6 KB) - added by skeltoac 6 years ago.
2959.diff Download (508 bytes) - added by mdawaffe 4 years ago.

Change History

  • 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   ryan6 years ago

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

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

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

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

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: ↓ 7   jhodgdon5 years ago

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

comment:6   ryan5 years ago

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

comment:7 in reply to: ↑ 5   dwzemens5 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.

  • Cc redbrandonk added
  • Milestone changed from 2.1.4 to 2.2
  • Keywords needs-patch added; has-patch 2nd-opinion removed
  • Milestone changed from 2.2 to 2.3
  • 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?

ariejan, "needs-patch"

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.

  • Owner changed from ariejan to mdawaffe
  • Status changed from assigned to new
  • 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.

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

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

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

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?

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

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

Note: See TracTickets for help on using tickets.