This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: results count made public

#34344
Ernest MarcinkoErnest Marcinko
Keymaster

Hi,

I’m afraid this might not be possible (with simple modifications at least). WordPress queries each post title separately on the fly, so changing them via the loop is often times not that simple.
There is a custom code you can try, but there it is very likely not going to work:

add_filter('posts_results', 'my_custom_posts_results', 9999999, 2);
function my_custom_posts_results($posts, $query) {
	if ( $wp_query->is_search() && $wp_query->is_main_query() ) {
		$page = isset($_GET['paged']) ? $_GET['paged'] - 1 : 0;
		$n = get_option( 'posts_per_page' ) * $page;
		$n = $n < 0 ? 0 : $n;
		foreach ( $posts as $k => &$post ) {
			$post->post_title = ($n + $k) . '. ' . $post->post_title;
		}
	}
	return $posts;
}