when i run the following code.

$args = array(
    'type'            => 'monthly',
    'limit'           => '',
    'format'          => 'option', 
    'before'          => '',
    'after'           => '',
    'show_post_count' => false,
    'echo'            => 1,
    'order'           => 'DESC',
    'post_type'     => 'post'
<option value=""> Select </option>
    wp_get_archives( $args ); 
?>  </select>

I got this output

<option> Select </option>
    <option value="http://test.astech-us.com/holistichivorce/2016/03/"> March 2016 </option>
<option value="http://test.astech-us.com/holistichivorce/2016/02/"> February 2016 </option></select>

but i need output like WordPress back end filter option. like this

    <select name="m" id="filter-by-date"><option selected="selected" value="0">All dates</option><option value="201603">March 2016</option><option value="201602">February 2016</option></select>



wp_get_archives creates its links with the function get_archives_link. this function returns plain HTML, but it has a filter you can hook into.

You can use the get_archives_link filter to manipulate your HTML with some regex.

function my_archives_link($link_html) {
    //TODO: my regex to manipulate the HTML
    return $link_html;


Further reading

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.