/ Published in: JavaScript
Highlights the current post/page in the Wordpress sidebar.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script type="text/javascript"> $(document).ready(function() { // Base URL var baseUrl = "http://www.yoursite.com/"; // You need to target your sidebar here, change #sidebar to your sidebar identifier (id) $("#sidebar a").each(function(){ var href = $(this).attr('href').replace(baseUrl,''); if (href == document.location.pathname) { $(this).addClass('current'); } }); }); </script>