WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#7518 closed defect (bug) (fixed)

WordPress is not emitting class="current_page_item" for a page used as static front page display

Reported by: yanggers Owned by: ShaneF
Milestone: 2.7 Priority: normal
Severity: minor Version: 2.7
Component: General Keywords: has-patch tested commit
Focuses: Cc:

Description

The problem is apparent when using themes with navigation headers that lists user-created pages, with the latest posts as "home" or front page by default. One such theme is MistyLook by Sadish, which is widely used both by Wordpress.com and self-setup bloggers. When the user sets the front page to be a static user-created-page, navigating to this "home" front page does not let the header know it is at "home" or front page, not letting the header to highlight the appropriate navigation header.

This problem has been discussed elsewhere, http://wprocks.com/forums/comments.php?DiscussionID=1009, and has been determined to be a Wordpress code issue rather than theme code issue. Specifically, WordPress is not emitting class="current_page_item" for a page used as static front page display.

Attachments (3)

7518.1.diff (1.1 KB) - added by ShaneF 7 years ago.
For 2.7.x Only
classes.php (25.2 KB) - added by betsyk 7 years ago.
See new lines 577-580
deprecated_get_settings.diff (537 bytes) - added by filosofo 7 years ago.

Download all attachments as: .zip

Change History (17)

comment:2 @betsyk7 years ago

Looks like this has re-surfaced in Trac. Here are the details of this problem: http://www.umaitech.com/cms/?p=27. Also, here's the current fix for WP 2.6: in classes.php, new lines 577-580:

if ( empty($current_page) ) {
if ($page->ID == get_settings('page_for_posts'))
$css_class .= ' current_page_parent';
}

comment:3 @westi7 years ago

  • Milestone changed from 2.6.1 to 2.6.2

2.6.1 has been released, moving to 2.6.2 milestone

@ShaneF7 years ago

For 2.7.x Only

comment:4 @ShaneF7 years ago

  • Owner changed from anonymous to ShaneF
  • Status changed from new to assigned

I worked on this myself ont he 2.7.x and DD32 pointed it out. This patch for the 2.7.x line fixes the problem. tested and working per my site: http://bugssite.org/

"Home" is the front page static. http://bugssite.org/

"Blog" is the posts-page. http://bugssite.org/blog/

Blog page now does "Blog | the rabbit hole" when viewing the overall look.
When looking at a single post in the blog the "Blog" tab gets the correct CSS to indicated that it's highlighted.

comment:5 @ShaneF7 years ago

  • Keywords has-patch tested commit added

comment:6 @ShaneF7 years ago

  • Type changed from defect to enhancement

comment:7 @ShaneF7 years ago

The only "problem" with this is that:

http://bugssite.org/about/ - About "Tab" Highlighted

http://bugssite.org/about/history/ - About "Tab" Highlighted

http://bugssite.org/about/history/wordpress-plugins/ - About "Tab" Not Highlighted since it's parent is "History" and I don't show the history. It might be prudent to do a check to get the root page id as it's going through the steps.

However in my case I do not show the tab "History" in which it would normally display, but I don't.

comment:8 @betsyk7 years ago

Hi,

I don't believe that solution will resolve the problem. The problem is that it doesn't pass the current_page_parent class and you need to catch all "empty" posts -- not just pick up the class from single posts (pages). This bug and the well-tested fix have been fully documented here since February:

http://www.umaitech.com/cms/?p=27.

Also see #6664. Attached is a revised classes.php file for WP 2.6.2

New lines 577-580:
if ( empty($current_page) ) {
if ($page->ID == get_settings('page_for_posts'))
$css_class .= ' current_page_parent';
}

@betsyk7 years ago

See new lines 577-580

comment:9 @ryan7 years ago

current_page_item appears to already be fixed. The current_page_parent fix looks good. I'll commit that against this ticket and close.

comment:10 @ryan7 years ago

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

(In [9299]) Set current_page_parent when using page_for_posts. Props betsyk. fixes #7518

comment:11 @betsyk7 years ago

Yea! Thanks Ryan! This will make a lot of WP designers very, very happy.

comment:12 @betsyk7 years ago

...and if you're not doing anything in Feb., come to WordCamp Denver with Matt!
http://denver.wordcamp.org/

comment:13 @filosofo7 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened
  • Type changed from enhancement to defect
  • Version set to 2.7

[9299] added the deprecated get_settings. Patch fixes.

comment:14 @Viper007Bond7 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.