Only get post_id

时间:2016-10-05 作者:Tristan de Jager

我有一个get\\u pages()函数。我的工作都很好,但我只希望所有post\\u id都在我的变量中。这可能吗?

提前谢谢。

$countries = get_pages(array(
    "hierarchical" => 0, 
    "sort_column" => "menu_order", 
    "sort_order" => "desc", 
    "meta_key" => "page_type", 
    "meta_value" => 2,
));

1 个回复
最合适的回答,由SO网友:websupporter 整理而成

Quick shot:

$countries = get_pages(array(
    "hierarchical" => 0, 
    "sort_column"  => "menu_order", 
    "sort_order"   => "desc", 
    "meta_key"     => "page_type", 
    "meta_value"   => 2,
));
$page_ids = array();
foreach ( $countries as $country ) {
    $page_ids[] = $country->ID;
}

相关推荐

如何获取`COMMENT_POST_ID`?

我已经提取了回复电子邮件。原始电子邮件保存为CPT,并在我的插件中作为票据使用。我希望回复邮件作为对原始邮件的评论。 for($j = 1; $j <= $total; $j++){ $mail = $emails->get($j); //This checks if the email is reply or not and if the email is reply make it comment to its original post.