2017-06-20 7 views
0

私はこれを使用しました動的特集画像 WPのプラグインです。このプラグインを使用すると、アップロードしたすべての画像が表示されます。WordPressで複数のおすすめ画像を表示するには?

しかし、この配列では1つの画像しか表示しません。

私はこれを試してみたが、動作しません:

if(class_exists('Dynamic_Featured_Image')) { 
global $dynamic_featured_image; 

$featured_images = $dynamic_featured_image->get_featured_images(); 
//print_r($featured_images); 

//You can now loop through the image to display them as required 
foreach($featured_images as $featured_image) { 
    echo "<img src='".$featured_image[1]['full']."'></a>"; 
} 

}

答えて

0

は、foreachループを使用しないでください。このプラグインを追加する必要があり、ちょうどあなたが望むアレイインデックスを使ってイメージをつかむ:

if(class_exists('Dynamic_Featured_Image')) { 

    global $dynamic_featured_image; 

    $featured_images = $dynamic_featured_image->get_featured_images(); 
    //print_r($featured_images); 

    //you don't need to loop through anything, just use the array index 
    echo "<img src='".$featured_images[1]['full']."'></a>"; 

} 
関連する問題