Support » Fixing WordPress » conditional statement navigation and unique id’s

  • Using these posts:
    Conditional Navigation Highlighting Problems
    http://wordpress.org/support/topic/162320?replies=2

    Style current Page differently for wp_list_pages?
    http://wordpress.org/support/topic/158749?replies=3

    Along with this codex page:
    Dynamic menu highlighting
    http://codex.wordpress.org/Dynamic_Menu_Highlighting

    I was able to edit some code to create my blog’s navigation with unique css id’s for each list item and have the css id change when you were on the corresponding page. I’m posting the code here in case it is useful to someone else:

    <ul id="nav">
    <li <?php if (is_home()) { echo "id=\"uhome\""; ?>><a href="<?php bloginfo('url') ?>/">home</a>
    <?php } else { echo "id=\"home\">";?><a href="<?php bloginfo('url') ?>/">home</a><?php }?></li>
    
    <li <?php if (is_page('archives') || is_single()) { echo "id=\"uarch\""; ?>>
    <a href="<?php bloginfo('url') ?>/archive">archives</a>
    <?php } else { echo "id=\"archive\">";?><a href="<?php bloginfo('url') ?>/archive">archives</a><?php } ?></li>
    
    <li <?php if (is_page('colophon')) { echo "id=\"uabt\""; ?>>
    <a href="<?php bloginfo('url') ?>/colophon">colophon</a>
    <?php } else { echo "id=\"about\">";  ?><a href="<?php bloginfo('url') ?>/colophon">colophon</a><?php } ?></li>
    
    <li <?php if (is_page('contact')) { echo "id=\"ucont\""; ?>>
    <a href="<?php bloginfo('url') ?>/contact">contact me</a>
    <?php } else { echo "id=\"contact\">";?><a href="<?php bloginfo('url') ?>/contact">contact me</a><?php } ?></li>
    </ul>

    I hope it helps someone in some way. 🙂

Viewing 1 replies (of 1 total)
  • wow, a selfless act as the first post in a thread… unbelievable 😉

    thanks for your contribution 😀

Viewing 1 replies (of 1 total)
  • The topic ‘conditional statement navigation and unique id’s’ is closed to new replies.