WordPress.org

Ready to get started?Download WordPress

Forums

once again: No "current_page_item" class if a page displays post(s) (8 posts)

  1. notknow
    Member
    Posted 4 years ago #

    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.

  2. esmi
    Theme Diva & Forum Moderator
    Posted 4 years ago #

    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.

  3. notknow
    Member
    Posted 4 years ago #

    No, it is a static page in which i use

    if(is_front_page()){query_posts('category_name=Tipps');}

    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.

  4. esmi
    Theme Diva & Forum Moderator
    Posted 4 years ago #

    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:

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

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

  5. Samuel Wood (Otto)
    Tech Ninja
    Posted 4 years ago #

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

  6. notknow
    Member
    Posted 4 years ago #

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

    Thanks a lot.

  7. Samuel Wood (Otto)
    Tech Ninja
    Posted 4 years ago #

    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.

  8. chelseyg
    Member
    Posted 3 years ago #

    wicked, reset worked a treat thankyou!!

Topic Closed

This topic has been closed to new replies.

About this Topic