使用一些自定义的post_id Wordpress获取post_title

时间:2015-03-15 13:11:09

标签: wordpress

我要做的是获得某些习俗的post_title 像这样

post 1 = "PHP"
post 2 = "ASP"
post 3 = "HTML"
post 4 = "CSS"

在数组中我想选择帖子编号1,3,4答案必须在循环中并获得此结果

PHP
HTML
CSS

1 个答案:

答案 0 :(得分:1)

$args = array('post__in' => array(1,3,4));
$posts = get_posts($args);
foreach ($posts as $p) echo $p->post_title.'<br>';