I've been asked if I can add an option for "Today" and "Yesterday" to the date filter dropdown at the top of the post list in the WordPress admin view. (This is the list that shows recent month/years.)

Date filter dropdown in post management list

Does anybody know any filter or action hook I could use to add a couple of options to this list? People have discussed adding a whole custom list here and here, but how about adding an option to one of the default lists?

  • I've just realised this is a bad way to go about it, because that dropdown list corresponds to GET param "m", whereas to get Today or Yesterday I'd have to use the "day", "monthnum" and "year" params. Jan 29, 2013 at 16:06

1 Answer 1


Man, you can not hook to that filter at all. I've followed the source code in order to find out whether there is any posibility, but unfortunately, there isn't. The function which generates select months_dropdown does not contains any filter at all.

months_dropdown function is a part of a WP_List_Table class and it's derivates (Classes extending WP_List_Table). So I checked whether there is an option to replace class generating table on edit.php, and againt, there isn't. All ends up in _get_list_table function, where all acceptable classes are hardcoded, again without an option to hook in. See bellow:

function _get_list_table( $class, $args = array() ) {
    $core_classes = array(
        //Site Admin
        'WP_Posts_List_Table' => 'posts',
        'WP_Media_List_Table' => 'media',
        'WP_Terms_List_Table' => 'terms',
        'WP_Users_List_Table' => 'users',
        'WP_Comments_List_Table' => 'comments',
        'WP_Post_Comments_List_Table' => 'comments',
        'WP_Links_List_Table' => 'links',
        'WP_Plugin_Install_List_Table' => 'plugin-install',
        'WP_Themes_List_Table' => 'themes',
        'WP_Theme_Install_List_Table' => array( 'themes', 'theme-install' ),
        'WP_Plugins_List_Table' => 'plugins',
        // Network Admin
        'WP_MS_Sites_List_Table' => 'ms-sites',
        'WP_MS_Users_List_Table' => 'ms-users',
        'WP_MS_Themes_List_Table' => 'ms-themes',

    if ( isset( $core_classes[ $class ] ) ) { ... } return false;

And this function is called directly from edit.php when assignig class. So you have to add another dropdown with today and yesterday options.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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