WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Has anyone written or can suggest a plugin that would replace the filter-by-month in the Post Administration screen with filter-by-week-number instead?

e.g. a drop down option for "Week of 05/31-06/06, 2011"

share|improve this question
up vote 2 down vote accepted

here you go , its something i quickly cooked up and it seems to work fine:

enter image description here

Plugin Name: admin-filter-by-week
Plugin URI: http://en.bainternet.info
Description: answer to Filtering posts on Post Administration Page by Week Number instead of by Month
Version: 1.0
Author: Bainternet
Author URI: http://en.bainternet.info

add_filter( 'parse_query', 'week_admin_posts_filter' );
add_action( 'restrict_manage_posts', 'ba_admin_posts_filter_restrict_manage_posts' );

function week_admin_posts_filter( $query )
    global $pagenow;
    if ( is_admin() && $pagenow=='edit.php' && isset($_GET['weekly_archive-dropdown']) && $_GET['weekly_archive-dropdown'] != '') {
        $link =  $_GET['weekly_archive-dropdown'];  
        $pos = strpos($link, '?m=');
        if ($pos !== false) {
            $m = substr($link, $pos + 3);
            $wpos = strpos($m, '&w=');
            $w = substr($m, $wpos + 3);
            $m = substr($m, 0, $wpos + 3);
            $query->query_vars['year'] = $m;
            $query->query_vars['w'] = $w;
            $query->query_vars['post_status'] = array('publish','pending','draft','future','private');

function hack_weekly_archives($w){
    $types = "IN('publish','pending','draft','future','private')";
    $w = str_replace("= 'publish'",$types,$w);
    return $w;

function ba_admin_posts_filter_restrict_manage_posts()
    <select name="weekly_archive-dropdown">
    <option value=""><?php echo esc_attr( __( 'Select Week' ) ); ?></option> 
    <?php wp_get_archives( 'type=weekly&format=option&show_post_count=1' ); ?>
share|improve this answer
That is fantastic. Thanks! – Justin Long Jun 3 '11 at 23:48
The one trick with doing it this way is that it only shows the weeks for items that are published--but not for items which are either draft or scheduled. I'm toying with it to try and see how to modify it to show weeks that are scheduled, too. – Justin Long Jun 3 '11 at 23:52
@Justin : i updated the code to show posts of all types – Bainternet Jun 4 '11 at 0:38
Thanks. It still doesn't seem to be showing the weeks in which there are only scheduled posts (e.g. no published posts). I'll look into it more tomorrow. – Justin Long Jun 4 '11 at 1:31
I think in the ba_admin_posts_filter_restrict_manage_posts, if I understand it right, wp_get_archives is only pulling weeks in which there are regular posts? and then week_admin_posts_filter is showing any posts published in those weeks. Is there any way to have wp_get_archives pull the weeks for which there are scheduled posts as well as published posts? – Justin Long Jun 4 '11 at 1:34

Your Answer


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.