WordPress.org

Ready to get started?Download WordPress

Forums

Page IDs and Navigational matrix (3 posts)

  1. tcherokee
    Member
    Posted 7 years ago #

    I wanted to find out if there is a way of assigning body id based on the page that you are on. For example, if you navigate to the about page, the body id will become <body id=about-page>.

    The reason I want to do this is because I'm using a css navigational system that relies on the body id to display the a hover and active states.

    Thanks in advance for your assistance

  2. Jeremy Clark
    Moderator
    Posted 7 years ago #

    Why not just use this.

    <ul>
    <?php
    $pg_li="page_item";
    if (is_home()) {$pg_li .=" current_page_item";}
    ?>
    <?php wp_list_pages('title_li='); ?>
    </ul>

    Then whenever the link in the menu is the current page then the class current_page_item is applied to that link then you can style that class any way you want. Just a thought.

  3. tcherokee
    Member
    Posted 7 years ago #

    Thanks, gotten it to work :)

Topic Closed

This topic has been closed to new replies.

About this Topic