Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a navigation menu in a page that highlights the current menu you’re on based on the URL by adding a class.

My problem is that my page is paginated, so sometimes the user will end up at:

http://example.com:4001/wordpress/calientes/page/2/ , /page/3/ , /page/4/ and so on...

what’s the best way to keep my menu highlighted while the user is browsing the pages?

This is my menu:

<div class="innerhead">

<ul>

<code><li> <a href="http://example.com:4001/wordpress/calientes/">Calientes </a> </li>
<li><a href="http://example.com:4001/wordpress/tendencias/">Tendencias</a></li>
</code>
</ul>

</div>

This is the Script that use to highlight the current page menu:

<script>
$(function(){
    // this will get the full URL at the address bar
    var url = window.location.href; 

    // passes on every "a" tag 
    $(".innerhead a").each(function() {
            // checks if its the same on the address bar
        if(url == (this.href)) { 
            $(this).closest("li").addClass("active");
        }
    });
});
</script>
share|improve this question
    
Close-voted as off-topic. As-written, this is a CSS/JS question, not a WordPress question. Per the WPSE FAQ, questions not specific to WordPress are out of scope, even if they happen in the context of WordPress*. –  Chip Bennett Oct 13 '13 at 23:00
1  
I don't understand why you're adding the class after the menu is clicked... Anyway, if you want help here, you should show the PHP you're using to build the menu; and how this pagination is happening. –  brasofilo Oct 14 '13 at 0:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.