(I've already opened a thread on stack overflow: https://stackoverflow.com/questions/30079269/wp-dynamic-featured-image-cant-get-second-featured-image-url Hope it's not considered as double)
I'm actually working on a wordpress website with a Dessign.net theme (the pixel one) which got a beautiful full-page slider on the front page. The slider shows the featured image of selected posts (post for which i've checked "show in slideshow" in the meta box field on edit page).
Those featured image are used in the same way for different view on the site (eg. thumbnails). I need them for the thumbnails, but i'ld like another image (still relative to selected posts) for the home-page slider.
I've found that "Dynamic Featured Image" plugins for wordpress but now i can't achieve to get the second featured image url in the slider's loop.
Here's the part of code for the slider, as it was with the theme:
<ul>
<?php
$slider_arr = array();
$x = 0;
$args = array(
//'category_name' => 'blog',
'post_type' => 'post',
'meta_key' => 'ex_show_in_slideshow',
'meta_value' => 'Yes',
'posts_per_page' => 99
);
query_posts($args);
while (have_posts()) : the_post();
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'full' );
//$thumb = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'large' );
$img_url = $thumb['0'];
?>
<li data-background="<?php echo $img_url; ?>" onclick="location.href='<?php the_permalink(); ?>';" style="cursor:pointer;">
</li>
<?php array_push($slider_arr,get_the_ID()); ?>
<?php $x++; ?>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</ul>
Now i've tried to put the code found on the plugin github page:
if( class_exists('Dynamic_Featured_Image') ) {
global $dynamic_featured_image;
$thumb = $dynamic_featured_image->get_featured_images( );
//You can now loop through the image to display them as required
}
in place of $thumb = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), 'full' );
But $thumb
return array
as a string
I tried a few different things but i'm not fluent in php.
Hope this is understandable.
$thumb = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
?$img_url
returning the DFI image URL?