因此,我试图仅显示介于开始日期 (st_date) 和结束日期 (end_date) 自定义字段之间的当前事件。目前,这对当前事件根本不起作用。
根据我的时区(东部)-5,我当前安装 Wordpress 的时间是正确的。
我试图更改我的 Wordpress 网站上的日期格式以匹配 Ymd,但是由于即将发生的和以前的事件都出现了,它显然没有帮助我。
是它正在工作的服务器时间吗?截至目前 12/31,它显示了一个开始日期为 12/30 的事件,而不是我创建的开始日期为 12/31 的事件。
这是我当前的代码。关于需要改变什么的任何想法?谢谢你的帮助!
//FILER FOR SEPARATING UPCOMING, CURRENT AND PAST EVENTS
function event_where($where)
{
global $wpdb,$wp_query;
$current_term = $wp_query->get_queried_object();
if((is_archive() || is_tag()) && ($current_term->taxonomy==CUSTOM_CATEGORY_TYPE1 || $current_term->taxonomy==CUSTOM_TAG_TYPE1))
{
if($current_term->taxonomy == CUSTOM_CATEGORY_TYPE1 || $current_term->taxonomy == CUSTOM_TAG_TYPE1)
{
if(@$_REQUEST['etype']=='')
{
$_REQUEST['etype']='current';
}
if(@$_REQUEST['etype']=='current')
{
$today = date('Y-m-d G:i:s');
$where .= " AND ($wpdb->posts.ID in (select $wpdb->postmeta.post_id from $wpdb->postmeta where $wpdb->postmeta.meta_key='st_date' and date_format($wpdb->postmeta.meta_value,'%Y-%m-%d %G:%i:%s') <='".$today."')) AND ($wpdb->posts.ID in (select $wpdb->postmeta.post_id from $wpdb->postmeta where $wpdb->postmeta.meta_key='end_date' and date_format($wpdb->postmeta.meta_value,'%Y-%m-%d %G:%i:%s') > '".$today."')) ";
}
elseif($_REQUEST['etype']=='upcoming')
{
$today = date('Y-m-d G:i:s');
$where .= " AND ($wpdb->posts.ID in (select $wpdb->postmeta.post_id from $wpdb->postmeta where $wpdb->postmeta.meta_key='st_date' and date_format($wpdb->postmeta.meta_value,'%Y-%m-%d %G:%i:%s') >'".$today."' and $wpdb->posts.post_status = 'publish')) ";
}
elseif($_REQUEST['etype']=='past')
{
$today = date('Y-m-d G:i:s');
$where .= " AND ($wpdb->posts.ID in (select $wpdb->postmeta.post_id from $wpdb->postmeta where $wpdb->postmeta.meta_key='end_date' and date_format($wpdb->postmeta.meta_value,'%Y-%m-%d %G:%i:%s') < '".$today."')) ";
}
}elseif(is_day() || is_month() || is_year())
{
$where = str_replace("'post'","'".CUSTOM_POST_TYPE1."'",$where);
}
}
return $where;
}