2017-08-21 75 views
0

我有數組產生ACF。我想顯示ID在數組中的所有帖子。 此代碼:只從數組顯示帖子 - WordPress

<?php 
echo '<pre>'; 
print_r(get_field('wpisyx')) ; 
echo '</pre>'; 
?> 

顯示我的所有ID:

Array 
(
    [0] => 911 
    [1] => 1088 
    [2] => 895 
    [3] => 1069 
    [4] => 915 
    [5] => 873 
    [6] => 470 
    [7] => 515 
    [8] => 1082 
    [9] => 844 
    [10] => 676 
    [11] => 697 
    [12] => 685 
    [13] => 516 
    [14] => 643 
    [15] => 620 
    [16] => 739 
    [17] => 522 
    [18] => 521 
    [19] => 646 
    [20] => 572 
    [21] => 551 
) 

我想要的職務序列是相同的表。

回答

3

您可以使用WP query,使循環用它

$query = new WP_Query(array('post__in' => get_field('wpisyx'))); 

然後,使用typic WP循環,在你需要的方式顯示出來:

if ($the_query->have_posts()) 
{ 
    echo '<ul>'; 
    while ($the_query->have_posts()) 
    { 
     $the_query->the_post(); 
     echo '<li>' . get_the_title() . '</li>'; 
    } 
    echo '</ul>'; 
    wp_reset_postdata(); 
} 
else 
{ 
    // no posts found 
} 
相關問題