WordPress pre_get_posts随机排序是复制的帖子


WordPress pre_get_posts ordered randomly is duplicating the posts

我在wordpress中使用pre_get_posts以随机顺序显示我的自定义帖子类型帖子。这有点工作,但它总是重复一些帖子意味着我结束了两个相同的帖子,当我点击加载更多。在刷新时,重复更改的帖子。他们有办法让它不重复帖子吗?

下面是我在函数中使用的使其随机显示的内容。

    function artist_random_display( $query ) {
    if ( $query->is_post_type_archive( 'artist' ) ) {
        $query->set( 'orderby', 'rand' );
    }
}
add_action( 'pre_get_posts', 'artist_random_display' );

这个函数没有什么问题,您只需要在显示此自定义帖子的页面上添加一个条件。