所以我使用了一个插件,当用户在单曲中向下滚动时,它会加载下一篇文章。php文件。在插件的主php文件中,有如下内容
// By default, don\'t query for a specific page of a paged post object.
// This argument can come from merging self::wp_query() into $query_args above.
// Since IS is only used on archives, we should always display the first page of any paged content.
unset( $query_args[\'page\'] );
$query_args = apply_filters( \'infinite_transporter_query_args\', $query_args );
$single_query = false;
if( isset( $_REQUEST[\'postID\'] ) && $_REQUEST[\'postID\'] != 0 ) {
$single_query = true;
$post_order = apply_filters( \'infinite_transporter_post_order\', self::get_settings()->post_order );
// Post type of initial post
$post_type = get_post_type( $_REQUEST[\'postID\'] );
// Allow filtering of initial post type by themes or plugins
$the_post_type = apply_filters( \'infinite_transporter_post_type\', $post_type );
// Only display posts from the same category as initial post
$in_same_cat = apply_filters( \'infinite_transporter_in_same_cat\', false );
if( $post_order ) {
$next_post = $this->infinite_transporter_get_adjacent_post( $_REQUEST[\'postID_order\'], $in_same_cat );
if( ! $next_post ) {
die();
}
$query_args = array(
\'p\' => $next_post->ID,
\'post_type\' => $the_post_type,
\'posts_per_page\' => 1,
);
} else {
$query_args = array(
\'posts_per_page\' => 1,
\'post_type\' => $the_post_type,
\'offset\' => $_REQUEST[\'page\'] - 1,
\'post__not_in\' => array( $_REQUEST[\'postID\'] ),
\'ignore_sticky_posts\' => true
);
}
$query_args = apply_filters( \'single_infinite_transporter_query_args\', $query_args );
}
我希望插件加载来自同一类别的帖子,我相信这是由
$in_same_cat = apply_filters( \'infinite_transporter_in_same_cat\', false );
. 然而,我不知道如何实现这段代码。如果有帮助的话,这个插件被称为Infinite Transporter。非常感谢您对如何实现该过滤器的任何帮助。