admin管理员组文章数量:1194359
I can't wrap my head around this and yes I've tried to flush the permalinks etc...
I've never encountered this before and a week ago it worked - I have not changed any code and it works on another website with the exact same theme.
anyway, I have a few custom post types and the problem is affecting all of these.
For example, let's take news.
In single-news.php I have a list showing the latest 10 news.
<?php
$query = new WP_Query(array(
'post_type' => 'news',
'post_status' => 'publish',
'posts_per_page' => 10,
'post__not_in' => [get_the_ID()],
));
while ($query->have_posts()) {
$query->the_post();
$newspost = '<li><a href="'.get_permalink(get_the_ID()).'">'.get_the_title().'</a></li>';
echo $newspost;
}
wp_reset_query();
get_permalink(), get_the_permalink() or the_permalink, nothing works.
The title works, get_the_ID() shows the correct post ID if I echo it, but the URL just returns site/news and not the url to the post.
For another post type, services, it just returns site/services
What's wrong here? I'm sure it's not the code, and I've tried deactivating plugins as well with no luck.
本文标签: Get permalink in custom post type loop doesn39t work
版权声明:本文标题:Get permalink in custom post type loop doesn't work 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738422518a2085936.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论