doutu6658 2013-12-30 21:55
浏览 36
已采纳

Wordpress - 获取帖子的链接

I want to display the thumbnail of a post. If the user clicks the thumbnail he gets directed to that post. But when clicking it I get a 403 ERROR. I'm new to php what is wrong?

PHP

<?php
query_posts('cat=5');
while (have_posts()) : the_post();

 the_title();

echo '<a href="<?php the_permalink();?>">';
    the_post_thumbnail();
echo '</a>';
endwhile;
?>
  • 写回答

5条回答 默认 最新

  • dtstnjl898781429 2013-12-30 22:14
    关注

    just replace your code

    echo '<a href="<?php the_permalink();?>">';
    

    TO :

    <a href="<?= the_permalink();?>">
    

    your code will be :

    <?php
    query_posts('cat=5');
    while (have_posts()) : the_post();
    
     the_title();
    ?>
    <a href="<?= the_permalink();?>"><?= the_post_thumbnail(); ?></a>
    <?php
    endwhile;
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 在使用pyecharts时出现问题
  • ¥15 深度学习残差模块模型
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计