Make WordPress Core

Opened 16 years ago

Closed 15 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's profile yanggers Owned by: shanef's profile 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 15 years ago.
For 2.7.x Only
classes.php (25.2 KB) - added by betsyk 15 years ago.
See new lines 577-580
deprecated_get_settings.diff (537 bytes) - added by filosofo 15 years ago.

Download all attachments as: .zip

Change History (17)

#2 @betsyk
16 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';
}

#3 @westi
16 years ago

  • Milestone changed from 2.6.1 to 2.6.2

2.6.1 has been released, moving to 2.6.2 milestone

@ShaneF
15 years ago

For 2.7.x Only

#4 @ShaneF
15 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.

#5 @ShaneF
15 years ago

  • Keywords has-patch tested commit added

#6 @ShaneF
15 years ago

  • Type changed from defect to enhancement

#7 @ShaneF
15 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.

#8 @betsyk
15 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';
}

@betsyk
15 years ago

See new lines 577-580

#9 @ryan
15 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.

#10 @ryan
15 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

#11 @betsyk
15 years ago

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

#12 @betsyk
15 years ago

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

#13 @filosofo
15 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.

#14 @Viper007Bond
15 years ago

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