Skip to:
Content
Pages
Categories
Search
Top
Bottom

make hand coded menu dynamic

  • Profile photo of admin25
    admin25
    Participant

    @admin25

    I have made a static menu and need it to be dynamic in that I need the selective menu item to have a background color.

    The problem is that the menu items are not static links but dynamic links made with
    <a href="activity/just-me/”>My Wall</a>

    so in my header.php I have:

    <a href="activity/just-me/”>My Wall
            <a href="activity/friends/”>My Friends' Activities</a>
    
            <a href="profile/edit/group/1″>Edit My Profile</a>

    and I am trying to style it with (also in header.php)

    `<?php
    if ( is_page(‘just-me’)) { $current = ‘one’; }
    elseif ( is_page(‘friends’) ) { $current = ‘one’; }
    elseif ( is_page(‘1′) ) { $current = ‘one’; }
    ?>

    # {
    background-color: yellow;
    }
    `

    Of course this does not work because the page names are not; “just-me”, “friend”, “1” these are part of the page slug names.

    is there a way to write
    `<?php
    if ( is_page(‘just-me’)) { $current = ‘one’; }
    elseif ( is_page(‘friends’) ) { $current = ‘one’; }
    elseif ( is_page(‘1′) ) { $current = ‘one’; }
    ?>`

    that inputs the slug? i.e something like:

    `<?php
    if ( is_page(slug(‘just-me’))) { $current = ‘one’; }
    elseif ( is_page(slug(‘friends’)) ) { $current = ‘one’; }
    elseif ( is_page(slug(‘1′)) ) { $current = ‘one’; }
    ?>`

    Thanks
    Tim

  • The topic ‘make hand coded menu dynamic’ is closed to new replies.
Skip to toolbar