将帖子URL链接到Slider上的缩略图
问题描述:
The below code pulls in all the thumbnails of posts in a category when you are viewing one of the posts in that category. I need to link the title of the post to the image.
<div id="workSlider" class="flexslider">
<ul class="slides">
<?php while (have_posts()) : the_post(); ?>
<?php $workthumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ),'full' );
if( $workthumb && $currentID != $post->ID ) {
echo '<li><a href=""><img src="'. $workthumb[0].'" ></a></li>';
}
?>
<?php endwhile; ?>
</ul>
</div>
当您查看该类别中的某个帖子时,以下代码会提取某个类别中帖子的所有缩略图 。 我需要将帖子的标题链接到图像。 p>
&lt; div id =“workSlider”class =“flexslider”&gt;
&lt; ul class =“ 幻灯片“&gt;
&lt;?php while(have_posts()):the_post(); ?&gt;
&lt;?php $ workthumb = wp_get_attachment_image_src(get_post_thumbnail_id($ post-&gt; ID),'full');
if($ workthumb&amp;&amp; $ currentID!= $ post-&gt; ID) {
echo'&lt; li&gt;&lt; a href =“”&gt;&lt; img src =“'。$ workthumb [0]。'”&gt;&lt; / a&gt;&lt; / li&gt;';
}
?&gt;
&lt;?php endwhile; ?&gt;
&lt; / ul&gt;
&lt; / div&gt;
code> pre>
div>
答
Try echo '<li><a href="' . get_the_permalink() . '"><img src="'. get_the_title() .'" ></a></li>';
I think this will work.