WordPress.org

Support

Support » Themes and Templates » Twenty Twelve » Thumbnails on Search

Thumbnails on Search

Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator Andrew Nevins

    @anevins

    Forum moderator

    May you provide a link to the problematic webpage? To clarify, the issue is you don’t have thumbnails on search results?

    Michael

    @alchymyth

    Forum Moderator

    the featured image is shown by this line in content.php (line 18):

    <?php the_post_thumbnail(); ?>

    wrap it into a conditional statement to exclude it in search results:

    <?php if( !is_search() )  the_post_thumbnail(); ?>

    http://njnnetwork.com/?s=Samsung

    That’s the search result

    Tried <?php if( !is_search() ) the_post_thumbnail(); ?>

    but had earlier rem’d that statement to avoid double images on single posts – one above the Post title and another after h1

    Line 18 works <?php // the_post_thumbnail(); ?>

    Michael

    @alchymyth

    Forum Moderator

    ok – you want to have the post’s image in the search result?
    (it seems that you were not referring to the ‘featured image’ aka post_thumbnail, but to a thumbnail in the post)

    before you proceed, strongly consider to create a child theme for your customisations; http://codex.wordpress.org/Child_Themes

    it is not recommended to edit any of the default themes directly.

    then edit content.php (a copy of content.php in your child theme):

    this section decides to show only excerpts for search results:

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    		<div class="entry-summary">
    			<?php the_excerpt(); ?>
    		</div><!-- .entry-summary -->
    		<?php else : ?>
    		<div class="entry-content">
    			<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>
    			<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
    		</div><!-- .entry-content -->
    		<?php endif; ?>

    remove the conditional structure and leave only:

    <div class="entry-content">
    			<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>
    			<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
    		</div><!-- .entry-content -->

    Sorry for the terminology mixup. I want to display the smaller image which is called the ‘150 x 150 thumbnail’ in insert media and I presumed is the ‘featured image’

    Without modification, search results displays the excerpt without an image. A Category search displays the first post image, which I want to change to the 150×150 image as well but one thing at a time.

    I experimented with removing conditional statements as suggested but none of my versions got an image.
    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    <div class="entry-summary">
    <?php the_excerpt(); ?>
    </div><!-- .entry-summary -->
    <?php else : ?>
    ....
    <?php endif; ?>

    I tried this code and got images, although not the right size (right after <?php if ( is_search() ) : // Only display Excerpts for Search ?>

                     <div class="the_post_thumbnail">
                     <?php the_post_thumbnail(150,150); ?>

    I put the 150 to enlarge some 50×50 thumbnails.

    What I want to do is size everything down to 150 pixels wide.

    It’s all working nicely except the text wrap

    word wrap fixed by align left statement.

    <hre><?php if ( is_search() ) : // Only display Excerpts for Search ?>
    <div class=”the_post_thumbnail”>
    <?php the_post_thumbnail(‘thumbnail’, array(‘class’ => ‘alignleft’)); ?>

    Thanks for your help and also for the documentation. Function Reference/the post thumbnail

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
         <div class="the_post_thumbnail">
         <?php the_post_thumbnail('thumbnail', array('class' => 'alignleft')); ?>
    

    fixed

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Thumbnails on Search’ is closed to new replies.
Skip to toolbar