matt-s
8/19/2015 - 7:29 PM

Filter posts by category

Filter posts by category

		<div class="styled-select">
			<?php $args = array(
				'show_option_none' => __( 'Filter Blog By Category' ),
				'orderby'          => 'name',
				'exclude'            => 1,
			); ?>
			<?php wp_dropdown_categories( $args ); ?>
			<script type="text/javascript">

			var dropdown = document.getElementById("cat");

				dropdown.addEventListener('change', function() {
				    if (dropdown.options[dropdown.selectedIndex].value > 0 )
						{
				        location.href = "<?php echo esc_url( home_url( '/' ) ); ?>?cat="+dropdown.options[dropdown.selectedIndex].value;
				    }

				});
			</script>
		</div> <!--/ styled-select -->