我有一個帖子ID的列表,我想循環的帖子,我已經嘗試使用WP_QUERY與post_in,但這並不保留該命令id的列在$ sorted數組中。WordPress的 - 循環了ID號碼數組中發現的帖子
什麼是最簡單的方式循環id的數組作爲職位,但覆蓋美國排序的排序的訂單的自然後序?
$args = array (
'post__in' => $sorted, // array of id's that I want in order
'posts_per_page' => -1, // so that it shows everything in the array
'ignore_sticky_posts' => 1 // so that stickys dont affect order
);
$query = new WP_Query($args);
// The Loop
if ($query->have_posts()) {
echo '<ul>';
while ($query->have_posts()) {
$query->the_post();
echo '<li>n' . get_the_title() . ' - '. get_the_ID() .'</li>';
}
echo '</ul>';
} else {
_e('Sorry, no posts matched your criteria.');
}
wp_reset_postdata();
你的意思是說,你想通過郵寄ID右門柱訂單? –
@ sameer-sheikh不列出數組$ sort中的ID的順序。覆蓋自然的後序。 – martyish