• queeneve

    (@queeneve)


    Thanks for the great plugin

    I have some question :
    I am using the woocommerce plugin and the ultimate search plugin to search the woocommerece products

    1) How can I show the product description instead of the excerpt in the search results?
    2) How can I show a fixed thumbnail in case the product doesn’t have a featured photo?

    TIA

    https://wordpress.org/plugins/ultimate-wp-query-search-filter/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author TC.K

    (@wp_dummy)

    What result template you using?

    If it is the ajax result template, you can use uwpqsf_result_tempt to customize the result.

    1) How can I show the product description instead of the excerpt in the search results?

    I am not sure but you can use the post content for product description.

    How can I show a fixed thumbnail in case the product doesn’t have a featured photo?

    First you have to add a fixed thumbnail uploaded to your site and used the image link.

    eg:

    add_filter('uwpqsf_result_tempt', 'customize_output', '', 4);
    function customize_output($results , $arg, $id, $getdata ){
    $query = new WP_Query( $arg );
    	$html = '';
    	if ( $query->have_posts() ) {
    	  $html .= '<h1>'.__('Search Results :', 'UWPQSF' ).'</h1>';
    	   while ( $query->have_posts() ) {
    	        $query->the_post();global $post;
    
    		$html .= '<article><header class="entry-header">';
                           //here check if got featured images, and used the uploaded image if not
    if ( has_post_thumbnail() ) {
                    $html .= get_the_post_thumbnail();
    }else{         //insert the uploaded image to the src
                   $html .= '<img src="http://yoursite.com/wp-content/uploads/xxx/default.jpg" >';
    
    }
    
    			$html .= '<h1 class="entry-title"><a href="'.get_permalink().'" rel="bookmark">'.get_the_title().'</a></h1>';
    			$html .= '</header>';
                            //here we add the content
    			$html .= '<div class="entry-summary">'.$post->post_content.'</div></article>';
    
    		  }
    			$html .= $this->ajax_pagination($pagenumber,$query->max_num_pages, 4, $id,$getdata);
    		 } else {
    					$html .= __( 'Nothing Found', 'UWPQSF' );
    				}
    				/* Restore original Post Data */
    				wp_reset_postdata();
    
    		return $html;
    
    }

    *please read the comments in the script.

    If you are using the default result template, then you will need to customize your theme’s search,php. You need to find the looping in this template (it might be in different template), that start with the while loop.

    The script above not tested, it might have some typo/syntax error, you should turn on the debug mode when using the script to make sure it run properly.

    Thread Starter queeneve

    (@queeneve)

    Thanks bro for your reply

    1- I am using the Default Search Template, as the ajax template is conflicting with my theme and it doesnot work , so how can I use the description to show on the search results in using the default theme?

    Plugin Author TC.K

    (@wp_dummy)

    This depends on your theme.
    But the step pretty much the same. Goto the theme’s search.php, and look for the while loop , and inside this loop, you can apply :

    for featured image:

    if ( has_post_thumbnail() ) {
                    $html .= get_the_post_thumbnail();
    }else{         //insert the uploaded image to the src
                   $html .= '<img src="http://yoursite.com/wp-content/uploads/xxx/default.jpg" >';
    
    }

    and for description, replace the get_the_excertp() or the_excerpt() into:
    $post->post_content, get_the_content() or the_content()

    The idea is same, you just need some coding skill to apply it.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘excerpt & thumbnail results.’ is closed to new replies.