そのため、開始日 (st_date) と終了日 (end_date) カスタム フィールドの間にある現在のイベントのみを表示しようとしています。現在、これは現在のイベントではまったく機能していません。
Wordpress インストールの現在の時間は、私のタイムゾーン (東部) の -5 で正確です。
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;
}