1
我想要使用wp_get_recent_posts()
獲得10個最近的帖子和頁面。我想顯示最近的帖子和特定模板的最近頁面。下面是我的代碼,但我沒有得到任何帖子。使用具有特定頁面模板的wp_get_recent_posts
$lastupdated_args = array(
'numberposts' => 10,
'orderby' => 'post_date',
'post_type' => array('page', 'post'),
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => '_wp_page_template',
'value' => 'tutorial.php', // template name as stored in the dB
)
),
);
//Loop to display 10 recently updated posts
$recent_posts = wp_get_recent_posts($lastupdated_args);
謝謝@Osama,我添加了這段代碼,並且只獲取頁面列表沒有帖子 – aje
'post_type'=> array('post','page'); – Osama
我將序列更改爲「後」,「頁」,但沒有運氣,結果相同。 – aje