Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

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.

share|improve this question
    
Wondering if this is not at all possible without modifying the core WP code? –  Justin Long Jun 7 '11 at 17:26
    
Ok I found out. There are a few less parameters in the backend. This was a good reference: wpsmackdown.com/easy-filter-posts-wordpress-admin –  Dan Dillon May 15 at 10:50
    
Answers should be more than plain links. They should actually be an answer instead of a route where someone will maybe find an answer. Please help preventing link rot, edit your answer and provide the needed information that helps the OP as well as later visitors to solve their problem. –  kaiser May 15 at 11:20

1 Answer 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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