Support » Themes and Templates » once again: No “current_page_item” class if a page displays post(s)

once again: No “current_page_item” class if a page displays post(s)

  • Hi,

    i was wondering for quite some time now about the fact that if i display (a) post(s) on a page the classname for indicating the active page, “current_page_item”, is missing.

    I then found this and happily tried to apply it to my “post-template.php” i figured that this file is no longer the same as the one mentioned in the ticket. Tried to apply the fix in line 420 – with no luck.

    The ticket is very old, working fixes seem to exist for older versions of wordpress – but i definitely need to get this fixed with 2.9.1.

    I first thought that “jpmcc_fold_page_menus_widget.php” is the culprit but now i don’t think so as this plugin mainly creates a exclude-list for wp_list_pages().

    So my question is if anyone can point me to some page/thread where this is discussed or, even better, solved.

    Thank you.

Viewing 7 replies - 1 through 7 (of 7 total)
  • esmi


    Forum Moderator

    Is this for the Posts page set via Admin/Settings/Reading/Front page displays? Only the current_page_item class works fine for me within that setup.

    No, it is a static page in which i use


    and the loop to display the posts.

    In the meanwhile i found out that the above condition is the part that somewhow kills the classname. The classname is there when i delete that condition from the code and disappears when i put it back in place.



    Forum Moderator

    I think that’s a different bug. The one covered in Trac related to the Posts Page as I mentioned above and was fixed. I also just carried out a test with a page template using:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args= array(
    	'cat' => 22,
    	'paged' => $paged

    And again, the current_page_item class was generated just fine when viewing the page.

    Try doing a wp_reset_query(); after you’re done with your special Loop.

    @otto42 – That did the trick.
    Will go and find out more about wp_reset_query();.

    Thanks a lot.

    wp_reset_query is very handy. Whenever you do any sort of custom query or mess with the global $post variable or what have you, then wp_reset_query will reset the query and $post back to the place they were supposed to be, eliminating any weird issues you might have with Loop values showing up in odd places.

    wicked, reset worked a treat thankyou!!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘once again: No “current_page_item” class if a page displays post(s)’ is closed to new replies.