使用date\\u query,我可以成功使用此代码:
$args = array(
\'post_type\' => \'projects\',
\'posts_per_page\' => -1,
\'orderby\' => \'title\',
\'order\' => \'ASC\',
\'date_query\' => array(
array(
\'after\' => date(\'Y\')-2
)
),
);
但“after”与我的第一个请求有一点不同,这段代码的作用与我的第一个请求相同:
$args = array(
\'post_type\' => \'projects\',
\'posts_per_page\' => -1,
\'orderby\' => \'title\',
\'order\' => \'ASC\',
\'date_query\' => array(
array(
\'year\' => date(\'Y\')-2
)
),
);