我有一个wordpress/php 显示网页上帖子列表的代码如下所示。
Php代码:
$special_reports = new \\WP_Query([
\'post_type\' => \'cpac-special-report\',
\'orderby\' => \'menu_order\',
\'order\' => \'ASC\',
\'fields\' => \'ids\',
\'posts_per_page\' => $data->{"toggle_multi_status"} == 2 ? 3 : 4
]);
调试时
<?php echo json_encode($special_reports); ?>
它显示以下内容:
{
"query": {
"post_type": "cpac-special-report",
"orderby": "menu_order",
"order": "ASC",
"fields": "ids"
},
"posts": [149443, 149551, 149488], /* Posts id here is displaying on the basis of weight order ASC */
"max_num_pages": 54
}
我现在在下面的php中想要什么,我想要
post id 149443 出现在
Line A 和
post ids 149551 and 149488 在
Line B.
<?php if ($data->{"toggle_multi_status"} == 2) { ?>
<?php if ($special_reports->have_posts()) : while ($special_reports->have_posts()) : $special_reports->the_post(); ?>
// Here I want to display post id 149443 (lets call as tile A) /* Line A */
<?php endwhile; endif;
<div class ="test">
<p>Some Content</p> // Here I am displaying tile B
</div>
<?php if ($special_reports->have_posts()) : while ($special_reports->have_posts()) : $special_reports->the_post(); ?>
// Here I want to display post ids 149551 and 149488 (lets call as tiles C and D) /* Line B */
<?php endwhile; endif;
<?php
}
?>
上述php代码的图形表示应为:
Tile A Tile B Tile C Tile D
149443 Some Content 149551 149488
Problem Statement:
我想知道我应该在上面的代码中做些什么更改,以便
1st post id 149443 displays at Line A 和
2nd/3rd post ids (149551 and 149488) display at Line B.