Show Products in search results (not only text)


#1

Hi,
Is there a way to show products and their product images in the search result page?
Don’t the text only results very appealing…
Thank you!


#2

Hello,

It needs some code customization in the theme files.

At first you need create child theme

Please copy over jupiter/views/templates/wp-search.php to jupiter-child/views/templates/wp-search.php. After that, edit wp-search.php and add the code below on line number 24.

<?php the_post_thumbnail(); ?>

You will get an image in the search result where the featured image is set.

Best regards,
Artbees Support.


#3

@Tatyana_Hutsol plz tell me how can i show product detail below it like price etc,

chk code here …

<?php esc_html_e( 'Not so happy with results? Search for a new keyword ', 'mk_framework' ); ?>

<?php Mk_SVG_Icons::get_svg_icon_by_class_name(true,'mk-icon-search',16); ?> <?php if ( have_posts() ): while ( have_posts() ) : the_post(); $post_type = get_post_type(); ?>
			<article class="search-result-item">
				<h4 class="the-title"><a href="<?php echo esc_url( get_permalink() ); ?>"><?php the_title(); ?></a></h4>
				<?php if ( has_post_thumbnail() ) {
						$url = get_permalink();
						echo '<a href="'.$url.'">';
						the_post_thumbnail();
						echo '</a>';
				} ?>


				<div class="search-loop-meta">
					<span><?php esc_html_e( 'By', 'mk_framework' ); ?> <?php the_author_posts_link(); ?></span>

						<time datetime="<?php the_time('Y-m-d'); ?>">
		
							<?php the_date('', '<time datetime="'.get_the_time().'">' . esc_html__( 'On', 'mk_framework' ) . ' <a href="'.get_month_link( get_the_time( "Y" ), get_the_time( "m" ) ).'">', '</a></time>'); ?>
							</a>
						</time>
					<?php
						echo '<span class="mk-search-cats">';
							switch ($post_type) {
	
								case 'post':
										echo esc_html__( 'In', 'mk_framework' ) . ' '.get_the_category_list( ', ' );
									break;
								case 'portfolio':
										echo esc_html__( 'In', 'mk_framework' ) . ' '.implode(', ', mk_get_custom_tax(get_the_id(), 'portfolio', true));
									break;	
								case 'news':
										echo esc_html__( 'In', 'mk_framework' ) . ' '.implode(', ', mk_get_custom_tax(get_the_id(), 'news', true));
									break;			
							}
						echo '</span>';
					?>
				</div>



				<div class="the-excerpt"><p><?php mk_excerpt_max_charlength(200) ?></p></div>
			</article>
<?php $post_type = ''; endwhile; mk_post_pagination(NULL); wp_reset_query(); endif; ?>