Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Results count
- This topic has 7 replies, 2 voices, and was last updated 3 years, 9 months ago by
Ernest Marcinko.
-
AuthorPosts
-
August 10, 2022 at 10:44 am #38792
Elie1978
ParticipantHello,
I want to display the results information box on the results page after each search
Resultat pour <strong>{phrase}</strong> (<strong>{results_count}</strong> de <strong>{results_count_total}</strong>)You can tell me where to add it, and I can do it.
Thank you for your help.
August 10, 2022 at 12:27 pm #38795Ernest Marcinko
KeymasterHi,
I can try to help you adding that, but first, make sure you are using a child theme from your original theme – so I will not try to modify the original theme files.
I tried to login to the backend, but the wp-admin and wp-login.php URLs are disabled, so I can’t. Can you please also add temporary FTP access, so I can make direct changes to the theme files?
August 17, 2022 at 9:40 pm #38929Elie1978
ParticipantYou cannot access this content.
August 18, 2022 at 10:22 am #38940Ernest Marcinko
KeymasterThank 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.
August 18, 2022 at 11:36 am #38949Elie1978
ParticipantYou cannot access this content.
August 18, 2022 at 12:03 pm #38954Ernest Marcinko
KeymasterHi,
You are welcome.
By default the plugin width is set to 100%, which means it follows the width of the container element – if that changes, then the plugin width also changes.
You can set the width to a fixed px value here: https://i.imgur.com/Xw5BTDj.pngAugust 18, 2022 at 12:37 pm #38957Elie1978
ParticipantThank you for help.
Good support, you can close the topic.
August 18, 2022 at 12:38 pm #38959Ernest Marcinko
KeymasterYou cannot access this content.
-
AuthorPosts
- The topic ‘Results count’ is closed to new replies.