thirteen
Member
Posted 2 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.
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?
your:
.current_page_item, .current_page_item a {
text-decoration: none;
color: #442604;
}
applies to pages, not to posts.
thirteen
Member
Posted 2 years ago #
thirteen
Member
Posted 2 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?
It is now when you made this dynamic http://marqspusta.com/7.0/news/
thirteen
Member
Posted 2 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
thirteen
Member
Posted 2 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?
That will do the trick if you want News to be your homepage.
thirteen
Member
Posted 2 years ago #
The problem is that the link in the navigation bar doesn't change when you're on the home page.
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?
thirteen
Member
Posted 2 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.
thirteen
Member
Posted 2 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=');?>
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=');?>
thirteen
Member
Posted 2 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.
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=');?>
thirteen
Member
Posted 2 years ago #
Doesn't seem to work. Thanks for your help so far. I will check back later...
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/
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!
thirteen
Member
Posted 2 years ago #
The issue with that is it's hard-coded, which means the "news" will remain highlighted on every other page too.
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 :(
thirteen
Member
Posted 2 years ago #
Don't worry about the extra PHP, I'm just deleting it.
<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 :)
thirteen
Member
Posted 2 years ago #
That worked! Thank you :)