-1
我正試圖將Flex Slider(flexslider.woothemes.com)與WordPress整合。我已經包含了所有需要的JS/CSS文件。
然後,我添加了此代碼以顯示某個類別的特色圖像 - 着名的WP_Query,其中$ args設置爲某個類別。然後使用echo the_post_thumbnail();我正在顯示帖子的圖片。它工作正常。我只需要將圖像鏈接到發佈的網址(img被hrefed)。請提前提供幫助和感謝。
<?php
$args = array(
'post_type' => 'post',
'category_name' => 'one',
'posts_per_page' => 5
);
// The Query
$the_query = new WP_Query($args);
// Check if the Query returns any posts
if ($the_query->have_posts()) {
// Start the Slider ?>
<div class="flexslider">
<ul class="slides">
<?php
// The Loop
while ($the_query->have_posts()) : $the_query->the_post(); ?>
<li>
<?php }
// The Slide's Image
echo the_post_thumbnail();
</li>
<?php endwhile; ?>
</ul><!-- .slides -->
</div><!-- .flexslider -->
<?php
// Reset Post Data
wp_reset_postdata();
?>
新代碼的工作:
<?php
$args = array(
'post_type' => 'post',
'category_name' => 'one',
'posts_per_page' => 5
);
// The Query
$the_query = new WP_Query($args);
// Check if the Query returns any posts
if ($the_query->have_posts()) {
// Start the Slider
?>
<div class="flexslider">
<ul class="slides">
<?php
// The Loop
while ($the_query->have_posts()) : $the_query->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>">
<?php echo the_post_thumbnail(); ?>
</a>
</li>
<?php endwhile; ?>
</ul><!-- .slides -->
</div><!-- .flexslider -->
<?php }
// Reset Post Data
wp_reset_postdata();
?>
不工作.../ – 2014-08-28 00:32:21
你是否試圖在相關文章的鏈接中包裝圖像?我理解那部分是對的嗎? – Kidcompassion 2014-08-28 00:50:05