WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Active page link colour (27 posts)

  1. thirteen
    Member
    Posted 3 years ago #

    Hello,

    I'm trying to figure out why the "News" link at the top of my page is not changing colours (like the "About" page) when active. I set it as the home page (through Settings > Reading), so I'd like the active link to be the correct colour when the user is on the home page AND the News page. Or at least the News page.

    Any help would be appreciated.

  2. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    http://marqspusta.com/7.0/news/ is post http://marqspusta.com/7.0/about/ is page, that's why :) This doesn't seem to be dynamic menu?

  3. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    your:

    .current_page_item, .current_page_item a {
    	text-decoration: none;
    	color: #442604;
    }

    applies to pages, not to posts.

  4. thirteen
    Member
    Posted 3 years ago #

    Yeah, it's not dynamic.

  5. thirteen
    Member
    Posted 3 years ago #

    OK, thanks, I changed it back to a dynamic menu. So how could I make the "News" link colour active when you're on the home page?

  6. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    It is now when you made this dynamic http://marqspusta.com/7.0/news/

  7. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

  8. thirteen
    Member
    Posted 3 years ago #

    Yup, that looks great. I'm concerned with the home page here. Or could I get rid of the home page somehow and make it the "News" page? I went to Settings > Reading and changed it to this: http://www.queueban.com/del/wp_active.png

  9. thirteen
    Member
    Posted 3 years ago #

    I basically want a way to change the "home" page name into "news", but I don't think WordPress allows this. I did make my own theme though, so perhaps there's a way I can code it?

  10. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    That will do the trick if you want News to be your homepage.

  11. thirteen
    Member
    Posted 3 years ago #

    The problem is that the link in the navigation bar doesn't change when you're on the home page.

  12. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    If the News is you current page on http://marqspusta.com/7.0/ the News will not be highlighted, only if you click on http://marqspusta.com/7.0/news/ but I don't think that this link should be even clickable if you made "news" as you home page via Settings.

    When you say the nav doesn't change what do you mean by that?

  13. thirteen
    Member
    Posted 3 years ago #

    The colour.

    I just changed the "Home" page back to recent posts instead of making it the "News" page. So you'll see two different links at the top. But still, the link doesn't change colour when you're on the second "News" link at the top, which is the home page.

  14. thirteen
    Member
    Posted 3 years ago #

    This is the code:

    <li><a href="<?php echo get_option('home'); ?>/" >News</a></li>
              <?php wp_list_pages('sort_column=menu_order&depth=1&title_li=');?>
  15. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    Second News is your Home so they don't highlight see the code now and News is highlighted once you click on it.

    <li><a href="<?php <?php echo home_url(); ?>/" >Home</a></li>
              <?php wp_list_pages('sort_column=menu_order&depth=1&title_li=');?>
  16. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

  17. thirteen
    Member
    Posted 3 years ago #

    Thanks, I'm going to look into it some more and see if there's a work-around. I really want the "news" link in the top to show itself as active when you're on the home page.

  18. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    Try this

    <li><a class="current_page_item" href="<?php <?php echo home_url(); ?>/" >News</a></li>
              <?php wp_list_pages('sort_column=menu_order&depth=1&title_li=');?>
  19. thirteen
    Member
    Posted 3 years ago #

    Doesn't seem to work. Thanks for your help so far. I will check back later...

  20. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    or

    <li class="current_page_item"><a href="<?php <?php echo home_url(); ?>/" >News</a></li>
              <?php wp_list_pages('sort_column=menu_order&depth=1&title_li=');?>

    Both tested on your site via chrome dev tool. http://postimage.org/image/31cspn738/

  21. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    oops!

    <li class="current_page_item"><a href="<?php echo home_url(); ?>/" >News</a></li>
              <?php wp_list_pages('sort_column=menu_order&depth=1&title_li=');?>

    didn't display right there was an extra php sorry!

  22. thirteen
    Member
    Posted 3 years ago #

    The issue with that is it's hard-coded, which means the "news" will remain highlighted on every other page too.

  23. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    for weird reason I am keep pasting an extra <?php I am so sorry about that
    please see the last one <?php echo home_url(); ?> above this post. My bad :(

  24. thirteen
    Member
    Posted 3 years ago #

    Don't worry about the extra PHP, I'm just deleting it.

  25. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    <li class="<?php if ( is_home() ) { echo "current_page_item"; } ?>"><a href="<?php echo home_url(); ?>/" >Home</a></li>
              <?php wp_list_pages('sort_column=menu_order&depth=1&title_li=');?>

    Last try :)

  26. thirteen
    Member
    Posted 3 years ago #

    That worked! Thank you :)

  27. Emil Uzelac
    Theme Review Admin
    Posted 3 years ago #

    No problem :-)

Topic Closed

This topic has been closed to new replies.

About this Topic