• Hi there

    I’m making a portfolio and I need to create a dropdown menu to filter post within a custom category by year.

    I found this piece of code. I included this into my archive.php but it brings all post no matter its category:

    <select name="archive-menu">
    <option value="">Select Year</option> <?php wp_get_archives('type=yearly&format=option'); ?>
    </select>

    Thanks!

Viewing 1 replies (of 1 total)
  • Hi Hernán, please try this code similar to the one described in wp_get_archives Codex page

    <select name="archive-menu" onchange="document.location.href=this.options[this.selectedIndex].value;">
    	<option value=""><?php echo esc_attr( __( 'Select Year', 'vionnet' ) ); ?></option>
    	<?php wp_get_archives( array(
    		'type' => 'yearly',
    		'format' => 'option',
    		'show_post_count' => 1
    	) ); ?>
    </select>

Viewing 1 replies (of 1 total)
  • The topic ‘Filter post within a category by year’ is closed to new replies.