posts_results

最后更新于:2021-11-27 15:24:19

apply_filters_ref_array( ‘posts_results’, GC_Post[] $posts, GC_Query $query )

Filters the raw post results array, prior to status checks.

参数

$posts

(GC_Post[])
Array of post objects.

$query

(GC_Query)
The GC_Query instance (passed by reference).

源文件

文件: gc-includes/class-gc-query.php

View on Trac

add_filter( 'posts_results', 'my_posts_results_filter' );

function my_posts_results_filter( $posts ) {
	$filtered_posts = array();
	print_r( $posts );
	foreach ( $posts as $post ) {
		if ( false === strpos($post->post_title, 'selfie')) {
			// safe to add non-selfie title post to array
			$filtered_posts[] = $post;
		}
	}
	return $filtered_posts ;
}