0

在我的博客上,我有一个名为“TGIF XACML”的类别。在每个帖子的末尾,我想使用 wordpress 短代码显示除当前帖子之外的同一类别中的帖子

[display-posts category="tgif-xacml"]

我试图弄清楚如何自动排除当前帖子。display-posts的参考页面没有将其列为选项。有办法吗?

如果您想查看当前状态,请查看此示例

谢谢。

4

1 回答 1

1

我不确定短代码,但使用函数你可以这样做:

<?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)
    ));
?>
于 2013-11-05T16:44:15.327 回答