WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Current page in sidebar (10 posts)

  1. matteograssini
    Member
    Posted 6 years ago #

    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?

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

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

  3. moshu
    Member
    Posted 6 years ago #

    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

  4. matteograssini
    Member
    Posted 6 years ago #

    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

  5. matteograssini
    Member
    Posted 6 years ago #

    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">

  6. <?php wp_list_pages('include=11,12,13,14&title_li='); ?>
  7. </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

  • Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

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

  • matteograssini
    Member
    Posted 6 years ago #

    Thanx Otto42 but which reference?

  • Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

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

    http://codex.wordpress.org/Dynamic_Menu_Highlighting

  • matteograssini
    Member
    Posted 6 years ago #

    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

  • matteograssini
    Member
    Posted 6 years ago #

    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 :-)

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags