Forums

Creating a Current Page Tab (9 posts)

  1. med103
    Member
    Posted 6 years ago #

    I followed this tutorial http://www.alistapart.com/articles/slidingdoors/ to make the tabs for my site. I added the current id selector to the blog page, just to see the difference between the current page tab and the others. Is there something I can add to the php or the like to make that id change to the current page so the tab state changes to the page I'm on?
    Thanks very much,
    Mike
    http://www.michaeldoig.net

  2. BPartch
    Member
    Posted 6 years ago #

  3. med103
    Member
    Posted 6 years ago #

    Sweet Thanks!

  4. med103
    Member
    Posted 6 years ago #

    That tutorial is great, but I can't seem to get it to work, I'm having an issue with adding an id to my pages. In the header.php file I have this to call my pages
    <-- <div id="portfolio_links">

      <li id="current">">Blog
      <?php wp_list_pages('title_li='); ?>

    </div> -->
    I understand that I need to change my current to something like page one or one, but how do I add an id to each of my pages?
    Thanks,

  5. moshu
    Member
    Posted 6 years ago #

    Just check out the source code of the list generated by wp_list_pages. It always adds a "current_page_item" class to the Page you are on.

  6. WarAxe
    Member
    Posted 6 years ago #

    moshu :: Wow, I didn't know that... For simple layouts (95% of blogs) that would be just the ticket! :-) I really should read that codex more often.

  7. med103
    Member
    Posted 6 years ago #

    Thank you moshu, I've got the tabs working properly now. The only thing left now is how do I get a blog link to appear when they are browsing anything blog related? I had a link like above that I got from the pool theme, but I can't seem to get it to turn off when it's not the blog. Thanks again for any help.

  8. med103
    Member
    Posted 6 years ago #

    I'm seriously going insane trying to get this blog tab to work...I'm trying to get the dynamic menu highlighting tutorial to work and so far I can only think of a few places I could have gone wrong. In the tutorial it says if ( is_page('Page One') ) page one would be the name of the page, that's the name in the title bar correct. Also this style part.
    <style type="text/css">
    #<?php echo $current; ?> {
    background-color: yellow;
    }
    </style>
    I need to add this to make it work, however I have another class I need to add. If I write it like this one I get a parsing error. When I check my code id='one' is not replace by what I specified in { $current = 'one'; } this part of the code. Any help would be greatly appreciated.
    Thank You,

  9. med103
    Member
    Posted 6 years ago #

    Thanks to the Regulus theme I figured out how to nake the tabs work http://www.binarymoon.co.uk/regulus/. All pages work with the current_page_item, but to make the blog/home tab work you need to add

    <li <?php if (((is_home()) && !(is_paged())) or (is_archive()) or (is_single()) or (is_paged()) or (is_search())) { echo "class=\"current_page_item\""; } ?> ><a href="<?php echo get_settings('home'); ?>" ><?php _e('Home'); ?></a></li>

    This will make the blog/home tab display the current_page_item class properly.
    Thanks,

Topic Closed

This topic has been closed to new replies.

About this Topic