WordPress Selected Nav Links

This is a post to share with the many people out there that probably have the same problem that I had today. So instead of you spending all your time trying to figure out this problem I am going to share with you my solution. Well to start off you need to know my problem I was creating a theme today and needed the nav links to be in a selected state when you were on that specific page. I had no clue how to do this in WordPress so I spent about 4 hours of my day looking up this problem. After that time I found the answer to my problem. The answer I am going to be showing is for the traditional header.php file that holds most everyone’s nav bar or your header links. All you have to do to have your page links to show in the nav and get them to be at a selected state as followed:

This part is for your Home Page so if you don’t want your home page than just don’t add this into your code.

<li id=”home” <?php if(is_home()) { ?> class=”selector” <?php } ?> ><a href=”<?php echo get_settings(‘home’); ?>”>Home<?php echo $langblog;?></a></li>

This is for the other pages that you have in WordPress.

<?php wp_list_pages(‘title_li=’);?>

Now all you have to do to get these links to be in a selected stage is add a little code to your css code which is as followed.

This is for home.

Your ID like #nav Then li.selector a {color: ###;}

This is for other pages.

Your ID like #nav Then li.current_page_item a {color: ###;}

Now some people like to have there categories do this same thing. Well all you have to do for that is change wp_list_pages to wp_list_categories so that it can list the categories. Then just change your css code from li.current_page_item to li.current-cat and you are finished.

If you have any questions about this just leave a comment of go to my Contact Page for my email.

Shane Strong
Chosen Development

About Shane

Hi I am Shane the main author of this blog. I am a self taught web developer. I have been working in this industry since 2008. I work a lot with WordPress, Magento, SEO & SEM, and custom built websites. I love all sports and I will try anything at least twice.

Working remotely is one of the fastest growing perks in the working world. It’s something that people talk about a lot, and it’s a solution to the “work/life balance” problem that bothers so many people. Most of us have asked the question, “Why do I work so hard?” For some people, there are many sides

Know little about the use of keylogger for Android? Wondering why so many friends choose free Android spy? What benefits can you get from tracking cell phones of your children and employees with the help of sms tracker? Keep reading and find the answers in this short article. Have you ever dreamed of taking control

As a photographer whether it be a hobby or on a professional level the realm of high dynamic range photography can be very troublesome without photo editing software specifically made for photo HDR. Aurora HDR photography can be very challenging as it is, but with Aurora the job gets a little bit easier. Some might

  • zerodx

    thank you so much!!!!!!!!!!!!!!!!!!!!!!

  • Britney Kate

    Thanks for this Great Information 🙂
    Very usefull information to all of us, especially i like your blog design, Very Attractive Design & Try to Add some Social Media Widget This will increase your blog visibility.
    I will bookmark this url to my facebook Account, will visit again.

    Britney

  • Hey, would you like to submit comments and backlinks to millions of blogs automatically? Blog Comment Poster will do it for you. Blog Comment Poster will increase your traffic, backlinks and earnings dramatically! Sounds cool? Yes, it is cool! It’s the best automated comments posting tool on the Internet with many advanced features. Check it out!

  • Stan

    Yep, took me 4 hours before I found your article about this as well. Thanks for posting the solution. Now time to sleep relieved.

  • buy bedding

    I am amazed with it. It is a good thing for my research. Thanks. ^_^

  • Great article! I’m loving your website;

  • Bookmark Links

    Hi there, I found your blog via Google while searching for bookmark links and your post regarding WordPress Selected Nav Links looks very interesting for me. Keep up the good work.