-1
私はcureently私は、今日$明日を$を使用しています、次のコード forループmeta_query配列の値WordPress?
$today = date('d');
$tomorrow = date('d', strtotime('+ 1 day'));
$thedayaftertomorrow = date('d', strtotime('+ 2 day'));
$current_month = date('m');
$next_month = date('m', strtotime('+ 1 month'));
$args = array (
'posts_per_page' => 4, // number of posts
'post_type' => 'employees', // your custom post type
'meta_key' => 'birthday', // your custom date field name
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'birthday',
'compare' => 'REGEXP',
'value' => '[0-9]{4}' . $current_month . $today,
),
array(
'key' => 'birthday',
'compare' => 'REGEXP',
'value' => '[0-9]{4}' . $current_month . $tomorrow,
),
array(
'key' => 'birthday',
'compare' => 'REGEXP',
'value' => '[0-9]{4}' . $current_month . $thedayaftertomorrow,
),
array(
'key' => 'birthday',
'compare' => 'REGEXP',
'value' => '[0-9]{4}' . $next_month . '[0-9]{2}',
),
)
);
私が代わりに値を繰り返すことで、配列の値の隣に30日間追加するforループを使用したいを持っており、新しい日を追加するために$ thedayaftertomorrow。
'($ I = 1; $ iの= 30 <;私は++ $)のためのようなもの{$日( '... 'のstrtotime(' +' $。私は「日」)); ...} '? – panther
動作しませんでした:( – Samarkandiy
何か間違っています。基本サイクルを調べてみてください。 – panther