WordPress.org

Ready to get started?Download WordPress

Forums

NOT THIS AGAIN - keeping current nav highlighted (7 posts)

  1. hkenna
    Member
    Posted 8 years ago #

    Hi,

    This is the address of my site, it is still being built http://www.type4screen.com

    I have been battling with trying to make the current navigation link remain highlighted...it just seems impossible. I feel really stupid posting this again.

    I have followed previously posted topics (http://wordpress.org/support/topic/27626) and I have tried to decipher (http://codex.wordpress.org/Dynamic_Menu_Highlighting) and I just can't understand (http://www.alistapart.com/articles/keepingcurrent/) in the context of a WP site.

    Can anyone tell me how to apply this in the context of wp kubrick theme? For example, my navigation is in the sidebar.php and it doesn't list each page in the code the way the examples cited above show it like this...

    <div id="navigation">

    </div>

    In my sidebar.php, as I understand it the navigation side bar is generated from the way wp pages and categories are created - so each item on my navigation bar is not listed explicitly as it appears in the examples. How do I specify ids for each of my pages and categories that are created within wordpress and where do I put these ids the sidebar.php code? The code from my sidebar.php is at the end of this post.

    Also in the header.php, what code do I write instead of the following (listed in the examples).
    <?php
    if ( is_page('Page One') ) { $current = 'one'; }
    elseif ( is_page('Page Two') ) { $current = 'two'; }
    elseif ( is_page('Page Three') ) { $current = 'three'; }
    elseif ( is_page('Page Four') ) { $current = 'four'; }
    ?>

    In the header.php, how should I specify each page that I have created eg. Introduction, Articles, Literature review etc...
    <?php
    if ( is_page('Introduction') ) { $current = 'introduction'; }
    elseif ( is_page('Articles') ) { $current = 'Articles'; }
    elseif ( is_page('Literature Review') ) { $current = 'Literature review'; }
    ?>

    Also this is the inline css that I put in the header.php, can you tell me what is wrong with this...
    <style type="text/css" media="screen">
    #<?php echo $current; ?> {
    color:#990000;
    background-image: url(images/arrow.gif);
    background-repeat: no-repeat;
    background-position: 0 .3em;
    padding-left: 12px;
    }
    </style>

    I have tried to follow the examples carefully but I just can't get them to work. I would be really grateful if anyone can explain how to do this in the context of WP. Big THNX.

    ----------
    MY SIDEBAR.PHP

    <div id="sidebar">

      <?php wp_list_pages('sort_column=menu_order&title_li=<h2>' . __('Research') . '</h2>' ); ?>

    • <h2><?php _e('Topics'); ?></h2>
        <?php list_cats(0, '', 'name', 'asc', '', 1, 0, 1, 1, 1, 1, 0,'','','','','') ?>
    • <h2><?php _e('Archives'); ?></h2>
        <?php wp_get_archives('type=monthly'); ?>
    • <?php get_links_list(); ?>

    • <h2><?php _e('Meta'); ?></h2>
      • <?php wp_loginout(); ?>
      • ">WordPress
      • <?php wp_meta(); ?>

      • <br></br>
        <?php include (TEMPLATEPATH . '/searchform.php'); ?>

    • <?php endif; ?>

    </div>

    ---

  2. davidsky
    Member
    Posted 8 years ago #

    See:
    http://codex.wordpress.org/Template_Tags/wp_list_pages

    When wp_list_pages is called while displaying a Page, the list item for that Page will be given the additional CSS class "current_page_item".

    Any method to do the same with categories ?

  3. hkenna
    Member
    Posted 8 years ago #

    Hi Davidsky,

    I am still lost. Sorry. Where is CSS class "current_page_item"? I thought the styling of the sidebar menu was controlled by the style.css. The dynmanic menu highlighting example tells you to use inline css in your header.php file instead to make current link active. My problem is still how to specify what is the current link and where/.how.
    Maybe we are not trying to do the same thing, sorry for the confusion.
    H.

  4. davidsky
    Member
    Posted 8 years ago #

    in wordpress 1.5+ the tag wp_list_pages for the select page create an html like this:

    < li class="page_item current_page_item" >TITLE< /li >

    you can change the layout of this li with css

  5. nearlythere
    Member
    Posted 8 years ago #

    davidsky, how did you get along with trying to get the same current_page_item for category?

    any progress?

  6. TechGnome
    Moderator
    Posted 8 years ago #

    current_page_item is for pages.... it indicates what is the currently displayed page..... categories are different. There is no class indicator for the current displayed category....

    -tg

  7. nearlythere
    Member
    Posted 8 years ago #

    i know that all too well. thank you for pointing out the cruel yet obvious, *sniff*. honest, i've been all up and down this topic, and searched well. but thank you TechGnome.

    i noticed davidsky in several places trying to get similiar functionality to having current_page_item with categories, and i wondered if he made any progress. so that's why i was writing him. to see what he resolved.

    (i'm using this plugin, http://adahas.com/work/cathighlight/ btw)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.