• Resolved matteograssini

    (@matteograssini)


    I’ve searched in the forum but I haven’t found an answer.
    This is the situation:
    – n.3 pages (page1,2,3)
    – i’m viewing the page 1 in the content area and I have a page list in the sidebar (page1,2,3)
    I want to highlight, in the sidebar, the page1 when I’m viewing the page1, the page2 when I’m viewing the page2 and the page3 when I’m viewing the page3.
    I’ve tried with the conditional tag current_page_item and relative class applied to a css with a:visited but it works when I see the page1 but when I saw all pages all the list in the sidebar is highlighted.
    Any suggestion, please?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    We would need a link to your page to see what you’re talking about.

    I’ve tried with the conditional tag current_page_item and relative class applied to a css with a:visited…
    Actually, it has nothing to do with “a:visited” – that one is a selector for items that ALREADY have been seen/clicked.

    Need to learn more about CSS… you jsut need to define the “current_page_item” in the stylesheet.
    More: http://codex.wordpress.org/Dynamic_Menu_Highlighting

    Thread Starter matteograssini

    (@matteograssini)

    I’ll send you the code relative to the header.php and page.php and of course the css relative to “current_page_item” tag.
    Thanx

    Thread Starter matteograssini

    (@matteograssini)

    This is my menu in hader.php

    <div class=”navigation”>
    NdC
    Master
    </div>

    This is part of page.php where I verify which page is requested

    <?php if (is_page(11) || is_page(12) || is_page(13) || is_page(14) ) {include (‘sidebar_ndc.php’); }
    elseif (is_page(15) || is_page(16) || is_page(17) ) {include (‘sidebar_master.php’); }
    else {include (‘sidebar.php’); }?>

    This is the entire sidebar_ndc.php file

    <div class=”sidenav”>

      <form method=”get” id=”searchform” action=”<?php echo $_SERVER[‘PHP_SELF’]; ?>”>
      <input name=”s” type=”text” id=”s” value=”<?php echo wp_specialchars($s, 1); ?>” size=”17″ />
      <input type=”submit” id=”sidebarsubmit” value=”Search” />
      </form>

    <ul class=”current_page_item”>

    • <?php wp_list_pages(‘include=11,12,13,14&title_li=’); ?>
    • </div>

      This is part of style.css

      .current_page_item li {
      color: #FF0000;
      }

      Backing to my original post, how can I resolve thet problem?
      Thanx.
      Matteo

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    moshu had the correct answer, look at his reference. Also, don’t use a:visited, just use a.

    Thread Starter matteograssini

    (@matteograssini)

    Thanx Otto42 but which reference?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Errr… The one moshu posted above. What other reference is there?

    http://codex.wordpress.org/Dynamic_Menu_Highlighting

    Thread Starter matteograssini

    (@matteograssini)

    oops….I tried but it doesn’t work or most probably I’m not good to make it work!
    Can you write me down an example based on my case.
    Be patient, I’m newby in PHP and WordPress.
    Thanx

    Thread Starter matteograssini

    (@matteograssini)

    I solved the situation with this CSS line:

    .page_item a {
    color: #554;
    }
    .current_page_item a:visited {
    color: #FF0000;
    }

    the first one restore the a color to they original one and the second color of red the a:visited link.
    Rude but it works 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Current page in sidebar’ is closed to new replies.