How to add a quicklink to the Posts Admin Published|Scheduled|Trash menu

Here might be an interesting idea: is it possible to add a “quicklink” to the quick links at the top of the Post Admin page (e.g. above the Bulk Actions dropdown, where it says “All | Published | Scheduled | Drafts | Pending”)?

My idea is to add a links for:
Today | Monday | Tuesday | Wednesday | Thursday | Friday

Read More

Just adding “Today” would be useful, as it would trigger the filter that shows all the posts that were either published or are scheduled for today.

Related posts

Leave a Reply

1 comment

  1. You can use the views_{screen_id} filter (used here), which filters an array where the keys act as an ID for that ‘view’ and the value is the HTML to be used to display the view (such as ‘All’, ‘Draft’, ‘Trash’ etc.).

    You can simply add extra links to this array:

    add_filter( 'views_edit-post', 'wpse_add_my_view');
    function wpse_add_my_view($views){
        global $post_type_object;
        $post_type = $post_type_object->name;
    
        $y =mysql2date('Y', current_time('mysql') );
        $m =mysql2date('m', current_time('mysql') );
        $d =mysql2date('d', current_time('mysql') );
        $views['today'] = "<a href='edit.php?year=$y&monthnum=$m&day=$d&post_type=$post_type'>".__('Today','myplugin')."</a>";
    
        return $views;
    }
    

    Of course – WordPress won’t automatically highlight your custom link (why would it?) – but to do that you you simply have to add the class current to the link when appropriate (check if the year, month and day are being queried?).

    By default WordPress adds this class to ‘all’ – so when you add the class you’ll also need to remove it from ‘all’ (otherwise they will both appear bold). To do that, you can either replace the ‘all’ value or preg_replace to remove the class.