您如何用简单的英语解释这段代码的含义?
'post__not_in' => array($post->ID)
如果有帮助,下面是完整的上下文。
// organise our options into a data object
$args = array(
'posts_per_page' => 3,
'orderby' => 'rand',
'post__not_in' => array($post->ID)
);
// a variable with our query and options
$query = new WP_Query( $args );
// do a loop with our new query code
if ($query->have_posts()): while ($query->have_posts()): $query->the_post(); ?>
<a href="<?php the_permalink(); ?>">
<h1><?php the_title(); ?></h1>
</a>
<?php endwhile; endif; ?>
答案 0 :(得分:2)
这段代码意味着,当您使用WP_Query随机获取3条帖子以显示相关帖子或类似内容时,'post__not_in' => array($post->ID)
会将当前帖子从该特定查询中排除。