You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WordPress中the_permalink方法异常:点击按钮无法跳转显示完整文章

问题解决:「继续阅读」按钮无跳转且无法在新页面打开文章内容

你的代码存在两个关键问题导致按钮功能异常:

  1. 缺少新页面打开属性:<a>标签未添加target="_blank",点击后无法触发新标签页跳转;
  2. 样式类拼写错误:card-dody是笔误,正确类名为card-body,这个错误可能导致卡片内容布局失效,让你误以为按钮无响应。

修正后的完整代码如下:

<?php if(have_posts()):while(have_posts()): the_post(); ?>
<div id="archive-section" class="card mb-3">
    <div class="card-body">
        <h3><?php the_title() ?></h3>
        <?php the_excerpt(); ?>
        <a class="btn btn-success" href="<?php the_permalink(); ?>" target="_blank">ادامه مطلب</a>
    </div>
</div>

<?php endwhile; endif;?>

修改说明:

  • 修正card-dody为card-body,恢复Bootstrap卡片内容区域的正常样式;
  • 在<a>标签中添加target="_blank"属性,实现点击按钮后在新标签页打开文章详情页。

内容的提问来源于stack exchange,提问作者ehsan ghorbani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 14:20:54