我有一个充满帖子ID的数组,$post_id = array(3,56,89,98);现在我要做的只是以表格格式显示帖子详细信息.如何在这里构建Wordpress循环?请在Wordpress中道歉我的新手知识并且要软.我真的需要一些方向.
实际上我认为Umesh的回答有问题.代替:
$post_id = array(3,56,89,98);
Run Code Online (Sandbox Code Playgroud)
它应该是:
$post_id = array( 'post__in' => array(3,56,89,98) );
Run Code Online (Sandbox Code Playgroud)
对?
我也开始学习php你需要做的事情
foreach ($post_id as $id) {
// do what ever you want to do here
}
Run Code Online (Sandbox Code Playgroud)
编辑
<?php
$post_id = array(3,56,89,98);
$posts = get_posts( $post_id);
foreach( $posts as $post ) :
setup_postdata($post); ?>
// you can call use post data inside here like
<h2 class="title"><?php the_title(); ?></h2>
<?php endforeach; ?>
Run Code Online (Sandbox Code Playgroud)