Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Results count › Reply To: Results count
August 18, 2022 at 10:22 am
#38940
Keymaster
Thank you!
I have added the following code to the functions.php file in the child theme directory:
add_action( 'elementor/widget/render_content', function( $content, $widget ){ // $content (string) = the rendered content of the widget; widget = the data object
global $wp_query;
if ($widget->get_name() === 'heading' && is_search() && !is_404() ) { // your targeted widget
//return "<h1>Resultat pour <strong>" . get_search_query() . "</strong> (<strong>".$wp_query->post_count."</strong> de <strong>".$wp_query->found_posts."</strong>)</h1>";
$settings = $widget->get_settings_for_display();
if ( '' === $settings['title'] ) {
return;
}
$widget->add_render_attribute( 'title', 'class', 'elementor-heading-title' );
if ( ! empty( $settings['size'] ) ) {
$widget->add_render_attribute( 'title', 'class', 'elementor-size-' . $settings['size'] );
}
//$title = $settings['title'];
$title = "Resultat pour '<strong>" . get_search_query() . "</strong>' (<strong>".$wp_query->post_count."</strong> de <strong>".$wp_query->found_posts."</strong>)";
if ( ! empty( $settings['link']['url'] ) ) {
$widget->add_link_attributes( 'url', $settings['link'] );
$title = sprintf( '<a %1$s>%2$s</a>', $widget->get_render_attribute_string( 'url' ), $title );
}
return sprintf( '<%1$s %2$s>%3$s</%1$s>', Elementor\Utils::validate_html_tag( $settings['header_size'] ), $widget->get_render_attribute_string( 'title' ), $title );
}
return $content;
}, 10, 2 );
This changes the title.