Results count

This topic contains 7 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 1 month, 2 weeks ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #38792
    Elie1978
    Elie1978
    Participant

    Hello,

    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.

    #38795
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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?

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #38929
    Elie1978
    Elie1978
    Participant
    You cannot access this content.
    #38940
    Ernest Marcinko
    Ernest Marcinko
    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.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #38949
    Elie1978
    Elie1978
    Participant
    You cannot access this content.
    #38954
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    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.png

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #38957
    Elie1978
    Elie1978
    Participant

    Thank you for help.

    Good support, you can close the topic.

    #38959
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Results count’ is closed to new replies.