Background:
I'm using a wordpress theme called skt full width. I am modifying their front page slideshow, so that it displays six random images instead of six pre-selected images. I have a custom field in media to select which images could be selected in this lottery to be on the front page. Then there is a query to select those images.
The code they use to display the images need certain image properties to be set in order to work. They are, image url, image title, image description, and image href.
Question:
How do I get that information needed from the media/attachment once it is in the query? Do I need to use their insertion code or is their a better way to accomplish what I want?
Code for displaying the image:
echo '{image : \''.$imgUrl.'\', title : \'<div class="slide-title"><span>'.( ($imgHref!='' && $imgTitle!='') ? '<a href="'.$imgHref.'">' : '').$imgTitle.( ($imgHref!='' && $imgTitle!='') ? '</a>' : '').'</span></div><div class="slide-description"><span>'.$imgDesc.'</span></div>'.( ($imgHref != '') ? '<div class="slide-description"><span><a href="'.$imgHref.'">Read More ›</a></span></div>' : '').'\', thumb : \''.$imgUrl.'\', url : \'\'},'."\n";
My code:
$args = array(
'post_type' => 'attachment',
'meta_key' => 'on_front_page',
'meta_value' => '1',
'orderby' => 'rand',
'posts_per_page' => 6 ,
'max_num_pages' => 1,
);
$slides = new WP_Query($args);
$total_images = (int) $slides->found_posts;
while( $slides->have_posts() ) {
echo '{image : \''.$imgUrl.'\', title : \'<div class="slide-title"><span>'.( ($imgHref!='' && $imgTitle!='') ? '<a href="'.$imgHref.'">' : '').$imgTitle.( ($imgHref!='' && $imgTitle!='') ? '</a>' : '').'</span></div><div class="slide-description"><span>'.$imgDesc.'</span></div>'.( ($imgHref != '') ? '<div class="slide-description"><span><a href="'.$imgHref.'">Read More ›</a></span></div>' : '').'\', thumb : \''.$imgUrl.'\', url : \'\'},'."\n";
}