[英]WordPress sidebar: make custom loop display posts in same category as single post, EXCLUDING current single post from the list
[英]In a wordpress post, display the list of posts that belong to the same category as the current post but exclude the current post itself
我不确定简码,但是使用函数可以这样:
<?php
global $post;
$this_post = $post->ID;
$related_query = new WP_Query( $args = array(
'post_type' => 'my_post_type',
'post_status' => 'publish',
'category' => 'tgif-xacml',
'post__not_in' => array($this_post)
));
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.