有没有人写过或者可以推荐一个插件,用“按周过滤”代替管理后屏幕中的按月过滤?
e、 g.“2011年5月31日至6月6日的一周”的下拉选项
有没有人写过或者可以推荐一个插件,用“按周过滤”代替管理后屏幕中的按月过滤?
e、 g.“2011年5月31日至6月6日的一周”的下拉选项
给你,这是我很快做出来的东西,看起来效果很好:
<?php
/*
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
http://wordpress.stackexchange.com/questions/19186/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\'];
//http://en.bainternet.info/?m=2011&w=22
$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()
{
add_filter(\'getarchives_where\',\'hack_weekly_archives\');
?>
<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\' ); ?>
</select>
<?php
remove_filter(\'getarchives_where\',\'hack_weekly_archives\');
}
在管理部分,我使用quesry帖子来获取自定义帖子的标题和内容此query\\u posts(\'post\\u type=sfnewsletter\');将获得我需要的内容,但不幸的是,我现在需要做的是通过表单传递自定义帖子的ID,然后检索该内容我试过了query_posts(\'p=32\'); query_posts(\'page_id=32\'); query_posts(\'page=32\'); query_posts(\'sfnewsletter_id=3