• Proudly using the twenty-eleven theme for wordpress and the latest version of woocommerce.

    I like having the main search bar on the site and how it pulls results from the products in my store and lists them in the results.

    The problem is it just loads text, I would like to show thumbnail size images too!

    Wondering how I can add a thumbnail of the product image/post relevant to each search result that comes up in the results. for example for this search result oceanic search on divesummit I would like it to display a thumbnail of the product image along with a snipper of the post.

    Any advice on how to change my code?

    Thanks for any help

    • This topic was modified 8 years, 2 months ago by jmarc4312.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Do not edit the theme itself. First create a child theme for your changes and create your own search.php template file.

    Thread Starter jmarc4312

    (@jmarc4312)

    Yes I do use a child theme, thanks for the reminder to only change the child.

    can you or someone direct me where I can discover functions and how to use the search.php file to load thumbnail sizes images of the posts?

    Thread Starter jmarc4312

    (@jmarc4312)

    currently my search.php is as follows:

    <?php
    /**
     * The template for displaying Search Results pages
     *
     * @package WordPress
     * @subpackage Twenty_Twelve
     * @since Twenty Twelve 1.0
     */
    
    get_header(); ?>
    
    	<section id="primary" class="site-content">
    		<div id="content" role="main">
    
    		<?php if ( have_posts() ) : ?>
    
    			<header class="page-header">
    				<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'twentytwelve' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
    			</header>
    
    			<?php twentytwelve_content_nav( 'nav-above' ); ?>
    
    			<?php /* Start the Loop */ ?>
    			<?php while ( have_posts() ) : the_post(); ?>
    				<?php get_template_part( 'content', get_post_format() ); ?>
    			<?php endwhile; ?>
    
    			<?php twentytwelve_content_nav( 'nav-below' ); ?>
    
    		<?php else : ?>
    
    			<article id="post-0" class="post no-results not-found">
    				<header class="entry-header">
    					<h1 class="entry-title"><?php _e( 'Nothing Found', 'twentytwelve' ); ?></h1>
    				</header>
    
    				<div class="entry-content">
    					<p><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'twentytwelve' ); ?></p>
    					<?php get_search_form(); ?>
    				</div><!-- .entry-content -->
    			</article><!-- #post-0 -->
    
    		<?php endif; ?>
    
    		</div><!-- #content -->
    	</section><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    I would like to add like a 150×150 pixel thumbnail of the featured image after the page title in the results

    udidol

    (@udidol)

    also looking to do something similar, if you found a solution let me know?

    udidol

    (@udidol)

    thanks

    Thread Starter jmarc4312

    (@jmarc4312)

    Still stumped, I do have a child theme already installed, do you know where I can find a template or examples of search.php files with the photo thumbnail showing for the results that I could use as an example to build off of?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘I need help adding thumbnail to search results in twenty-eleven theme’ is closed to new replies.