I am going by this tutorial ( https://redvinestudio.com/how-to-build-isotope-portfolio-in-your-wordpress-theme/的php echo语句,当我处理投资组合项目显示为链接的部分时,链接指向的网址正在显示在项目上方。以下是规定的代码:
echo '<div class="all portfolio-item '. $tax .'">';
echo '<a href="'. the_permalink() .'" title="'. the_title_attribute() .'">';
echo '<div class="thumbnail">'. the_post_thumbnail('thumbnail') .'</div>';
echo '<h2>'. the_title() .'</h2>';
echo '</a>';
/*echo '<div>'. the_excerpt() .'</div>';*/
echo '</div>';
答案 0 :(得分:1)
您无法在the_permalink()
中使用echo
,因为echo
数据本身。相反,您需要使用get_permalink()。您还需要修改the_title_attribute()
以避免重复echo
:
echo '<a href="'. get_permalink() .'" title="'. the_title_attribute( 'echo=0' ) .'">';
编辑:您需要梳理代码以删除在echo
内回显内容的所有代码实例。其中包括the_title()
,the_post_thumbnail()
等
答案 1 :(得分:0)
the_permalink()将始终回显对象的URL,这意味着您要告诉它回显两次。将其更改为get_permalink(),它应该可以工作。