admin管理员组文章数量:1432573
I'm not sure how to word this one at all so suggestions welcome. I'm using this code in functions.php to output a list of posts with anchors on archive.php and home.php
function output_link() {
// this outputs an external custom url for the 'resource' post type
if (is_post_type_archive( 'resources' )) {
return 'https://' . get_field('website');
}
return get_the_permalink();
}
home.php (blog archive)
<div class="blog-container">
<?php
if (have_posts()):
while (have_posts()):
?>
<div class="card container">
<a href="<?= output_link();?>">
<div class="card-body row"><?php
the_post();
?>
<div class="col-sm img-fluid post-image"><?php
the_post_thumbnail('medium');
?></div>
<div class="col-sm p-2 m-0">
<h2 class="card-title text-center"><?php the_title();?></h2>
</a>
<p class="card-text"><?php the_excerpt();?></p>
</div>
</div> <!-- card body -->
</div><!-- card -->
<?php
endwhile;
endif;
?>
</div>
when I click on any post link in the blog, or the 'programmes' or 'events' CPTs it takes you not to the post you clicked on, but the following one.
Example: The link for 'Post 1' leads to 'Post 2', the link for 'Post 2' leads to 'Post 3', and so on... While the last post in the list works normally, i.e 'Post 4' leads to 'Post 4'
Any idea what's causing this?
Thanks!
本文标签: permalinksCPT links error each one links to next one further along in the list
版权声明:本文标题:permalinks - CPT links error: each one links to next one further along in the list 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745604830a2665777.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论