Good day! I am building this Blog Archive page and it requires filtering of posts by months, using dropdown. Any idea how to do this?
<?php
// what goes here
printf('<option value=".%s">%s</option>', `what_here`, `what_here`);
?>
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You can try to use wp_get_archives() function.
Example from this link:
<select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value=""><?php esc_attr( _e( 'Select Month', 'textdomain' ) ); ?></option>
<?php wp_get_archives( array( 'type' => 'monthly', 'format' => 'option', 'show_post_count' => 1 ) ); ?>
</select>
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0
