WordPress中the_permalink方法异常:点击按钮无法跳转显示完整文章
问题解决:「继续阅读」按钮无跳转且无法在新页面打开文章内容
你的代码存在两个关键问题导致按钮功能异常:
- 缺少新页面打开属性:
<a>标签未添加target="_blank",点击后无法触发新标签页跳转; - 样式类拼写错误:
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
相关产品推荐
相关产品推荐

