我使用了WP的 动态特色图片 插件,当我使用这个插件时,它会显示我上传的所有图片。
但我只是想在这个数组中只查看一个图像。
我试试这个,但不起作用:
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 :(得分:0)
Multiple Featured wordpress plugin
您必须添加此插件
答案 1 :(得分: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>";
}