WordPress.org

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Plugin API/Filter Reference/posts results

Usage

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 ;
}
add_filter( 'posts_results', 'my_posts_results_filter' );

Input

The input of this filter is an array of posts, created by any(?) WP_Query looking for posts.

Return

The altered posts array.

Return to Plugin API/Filter Reference