Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › results count made public › Reply To: results count made public
August 23, 2021 at 2:15 pm
#34344
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;
}