donglun1020 2015-07-21 23:48
浏览 51
已采纳

我的<a href="#">的php echo语句使网址可见

I am going by this tutorial (https://redvinestudio.com/how-to-build-isotope-portfolio-in-your-wordpress-theme/), and when I am working on the part where the portfolio items are displayed as links, the url that the link leads to is being displayed above the item. Below is the prescribed code:

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>';
  • 写回答

2条回答 默认 最新

  • dongshi1869 2015-07-21 23:52
    关注

    You can't use the_permalink() within an echo, because it echoes data itself. Instead, you need to use get_permalink(). You also need to modify the_title_attribute() to avoid a duplicated echo there:

    echo '<a href="'. get_permalink() .'" title="'. the_title_attribute( 'echo=0' ) .'">';
    

    EDIT: You need to comb through your code to remove all instances of code that is echoing content within an echo. This includes the_title(), the_post_thumbnail(), etc.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改