Forums

Problem with "current_page_item" navigation highlighting (45 posts)

  1. Metaleks
    Member
    Posted 4 years ago #

    I also noticed (just tried it out) that in 2.2.2 this is still a concern.

    Is it a bug?

  2. Juissi
    Member
    Posted 4 years ago #

  3. karstenvennemann
    Member
    Posted 4 years ago #

    Hi,
    I was trying to get that to work for the last two months (off and on), however it's really still a bug in the newest version (http://wordpress.org/support/topic/107583) and the only way to solve it was (at least for me) to deinstall the newest wordpress and installing WP 2.1.0 instead - works great now!
    Karsten

  4. munzli
    Member
    Posted 4 years ago #

    well a quickfix ist to change the line (around 512) in the wp-includes/classes.php from:
    if ( $page->ID == $current_page )
    to:
    if ($page->ID == $current_page || ($current_page == 0 && $page->ID == get_settings('page_for_posts')))

  5. walterego
    Member
    Posted 4 years ago #

    Has anybody filed a ticket in trac about this?

  6. vossavant
    Member
    Posted 4 years ago #

    munzli,

    Your solution worked for me. However, instead of selecting a "Posts page" from the WordPress Options->Reading menu, I use a custom page template that lists posts from a single category. The page ID for this is 58, so I modified your code to read:

    if ($page->ID == $current_page || ($current_page == 0 && $page->ID == '58'))

    This change (on line 512 of classes.php) saved me a headache. Thanks so much.

    btw - running version 2.2.3

  7. tbaggett
    Member
    Posted 4 years ago #

    Just adding myself to the list of WP users afflicted by this bug ("current_page_item" class not being inserted when custom posts page is displayed). It still exists in version 2.3.1.

  8. buzzy
    Member
    Posted 4 years ago #

    I am trying to fix the same bug in version 2.3.1. Juissi above has a workaround, but I think it misses the point because - as far as I can tell - it will not work unless you hard code the navigation menu items, which defeats the purpose. My customers need to be able to add more pages themselves without my having to recode the navigation every time they do this.

    I hope this bug is a top priority. Thanks!

  9. analogpanda
    Member
    Posted 4 years ago #

    munzli's fix worked for me (thanks, munzli!)

    I had this problem in version 2.2 and still have it in 2.3.1

    I'll check the trac and report this bug if it hasn't yet been reported

  10. Ryan Hellyer
    Member
    Posted 4 years ago #

    A challenge was posted at WordPress.com about this issue ... http://wordpressgarage.com/wordpress-as-cms/wordpress-challenge-getting-class-current_page_item-to-work-when-home-page-is-not-blog/

    And I've posted a crude method to fix it (without altering core files) here ... http://ryanhellyer.net/test/wordpress1/blog/

  11. baudesign
    Member
    Posted 4 years ago #

    Well thanks to you guys, and thanks to Google! I have been scratching my head for the last four hours to finally having found this post.

    I use the latest WP version 2.3.1 and the bug is obviously still there.

    The solution from munzli above worked fine for me. Thanks for suggesting it.

    Now... good night.

  12. lomtas
    Member
    Posted 4 years ago #

    I solved this problem by making a plugin. Install the plugin and replace wp_list_pages() with list_pages_bugfix(). You find the plugin here: http://thomas.lippert.it/v4/wordpress-plugins/current-page-bugfix/

  13. walterego
    Member
    Posted 4 years ago #

    I'd like to testify that lomtas' plugin works great. The latest version even gives the blog page item a current_page_parent class when viewing a single post!

  14. wagonlips
    Member
    Posted 4 years ago #

    Danke, Thomas.

  15. betsyk
    Member
    Posted 4 years ago #

    I had this same problem on 2 sites running 2.3.2. I have detailed the issue (along with troubleshooting steps) here:

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

    Munzli's workaround fixes this bug -- ADD it as a second elseif statement as lines 520 and 521 in the classes.php file.

    elseif ($page->ID == $current_page || ($current_page == 0 && $page->ID == get_settings('page_for_posts')))
    			$css_class .= ' current_page_parent';

    This ensures that top-level navigation on both child pages and category pages retains the current_page_item class.

Topic Closed

This topic has been closed to new replies.

About this Topic