我已经建立了一个"滑块"用于Wordpress网站的推荐。推荐书是作为自定义帖子类型构建的。我正在循环并抓取某些信息,比如the_excerpt(),我也抓住附加的媒体;这是推荐书的音频文件。由于某种原因,我无法弄清楚,这个循环仅为第一篇文章获取附加媒体;其余的都是空白的,即使它们确实具有以完全相同的方式上传的相同类型的音频文件。请帮忙!他们为jQuery和CSS目的得到了一个偶数* / odd *的类。
<?php $loop = new WP_Query( array( 'post_type' => 'Testimonials', 'posts_per_page' => 6, 'orderby' => 'ASC' ) );
$counter = 1;
while ( $loop->have_posts() ) : $loop->the_post();
echo '<div id="testimonialPost'; echo $counter; echo '" class="'; echo (($counter % 2) == 1) ? "Odd" : "Even"; echo $counter; echo (($counter % 2) == 1) ? " Odd" : " Even"; echo '">';
echo '<div class="testimonialCopy volkorn blue">';
the_excerpt();
echo '<a class="audioTestimonial sourceSansPro bold gray" href="/testimonials">Click to hear more from our clients</a>';
echo '</div><!--.testimonialCopy-->';
echo '<div class="testimonialInformation">';
echo '<div class="featuredImage">';
the_post_thumbnail();
echo '</div><!--.featuredImage-->';
echo '<div class="nameAndStuff"><h2 class="name sourceSansPro blue">';
echo get_the_title();
echo '</h2><!--.name-->';
echo '<h2 class="nativeLanguage sourceSansPro blue">';
echo extra_information_get_meta( 'extra_information_extra_information_native_language' );
echo '</h2><!--.nativeLanguage-->';
echo '<a>Hear my audio testimonial</a>';
echo '</div><!--.nameAndStuff-->';
echo '</div><!--.testimonialInformation-->';
echo '</div><!--.testimonialPost-->';
$audio_attachments = get_posts( array(
'post_parent' => $loop->the_post,
'post_type' => 'attachment',
'post_mime_type' => 'audio'
) );
$audio_attachment_url = wp_get_attachment_url( $audio_attachments->ID );
$audioAttr = array(
'src' => $audio_attachment_url,
'loop' => $loop,
'autoplay' => '',
'preload' => 'none'
);
echo '<div class="packagePop audioTestimonialPop" style="display:none;"><div class="closeBtn"></div>'. wp_audio_shortcode( $audioAttr ).'</div>';
$counter += 1;
endwhile; wp_reset_query(); ?>