在我的博客上,我有一个名为"TGIF XACML"的类别。在每篇文章的末尾,我想使用 wordpress 短代码显示同一类别的帖子,除了当前帖子之外的帖子
[display-posts category="tgif-xacml"]
我正在尝试弄清楚如何自动排除当前帖子。显示帖子的参考页面未将其列为选项。有办法吗?
如果要查看当前状态,请查看此示例。
谢谢。
我不确定短代码,但是使用函数可以像这样做:
<?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)
));
?>