WordPress.org

Ready to get started?Download WordPress

Forums

Custom page templates and current_page_item (6 posts)

  1. PaulGrahamRaven
    Member
    Posted 5 years ago #

    Greetings boys and girls;

    An install I'm working on is using current_page_item to style a list of pages as a navigation menu, as seems pretty standard. The site uses a 'normal' front page (i.e. a list of recent posts, no special static frontpage selected).

    However, there's a problem - two of those pages are using custom page templates, and when those templates are used, current_page_item isn't passed. I thought it might be the second loop running after the page content loop causing the problem, but dummy versions minus the second loop still cause the same issue. Using the standard page template, current_page_item seems to work fine.

    Has anyone else encountered this little issue, and - more importantly - does anyone know a way around it? I've found hacks for similar problems caused by static front pages, but a) they're messy, and b) they don't address this problem, which seems to be simpler in origin (though I may be mistaken on that point, of course).

    Any suggestions?

  2. aledan
    Member
    Posted 5 years ago #

    I have same problem. Any solution? Thanks

  3. Steffen Jørgensen
    Member
    Posted 5 years ago #

    could it be done by using conditional tags?

    <li class="<?php if (is_page('7') || $post->post_parent == '7' ){echo 'current_page_item';} ?>">link goes here</li>

  4. bh
    Member
    Posted 5 years ago #

    I have the same problem as this. Any updates?

  5. alvarix
    Member
    Posted 5 years ago #

    Same problem here. Conditional tags are no solution if you want to use the wp_list_pages function. If your going to hack, may as well just use css.

    As I've been researching, Ive seen that this issue was prevalent around a year ago, version 2.3 or thereabouts. The bug has resurfaced it seems.

    I am using 2.7.1

  6. mixedbredie
    Member
    Posted 5 years ago #

    Same problem using latest WP 2.8.1, latest K2 rc8 theme and latest version of Now Reading Reloaded. This plugin includes a custom page template. The current_page_item class gets applied to the Posts/Blog front page rather than the Library page.
    Does anyone have any working solution? Has the bug been submitted?

Topic Closed

This topic has been closed to new replies.

About this Topic