Return to Snippet

Revision: 20075
at November 6, 2009 05:48 by dmatranga


Updated Code
<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>

Revision: 20074
at November 6, 2009 05:48 by dmatranga


Initial Code
<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('hover');
		}
	});
});
</script>

Initial URL


Initial Description
Highlights the current post/page in the Wordpress sidebar.

Initial Title
Highlight Current Post in Wordpress Sidebar

Initial Tags
javascript, wordpress, jquery

Initial Language
JavaScript