WordPress.org

Ready to get started?Download WordPress

Forums

Better Search
[resolved] Display thumbnails on search results page (8 posts)

  1. Creatrix
    Member
    Posted 9 months ago #

    Hi,

    Great plugin!

    Is there any way to display the posts thumbnail on the search results page?

    Would including <?php echo get_the_post_thumbnail( $post_id, $size, $attr ); ?> on the better-search-template.php work?

    http://wordpress.org/plugins/better-search/

  2. Ajay
    Member
    Plugin Author

    Posted 9 months ago #

    Unfortunately, I have not yet coded a way to put in the thumbnails. I'm working on a version that makes this a better and cleaner process.

    Right now the only way is to edit better-search.php and add the code in around line 165:

    https://plugins.trac.wordpress.org/browser/better-search/tags/1.3.1/better-search.php

    Something like this should work

    <?php echo get_the_post_thumbnail( $search->ID, $size, $attr ); ?>
  3. pxjenkins
    Member
    Posted 8 months ago #

    Would like to follow up on this: I tried simply pasting above code into better-search.php using Genesis Dynamik theme, so that the code looks like this:

    $output .= '<h2><a href="'.get_permalink($search->ID).'" rel="bookmark">'.$post_title.'</a></h2>';
    				$output .= '<p>';
    				$output .= get_bsearch_score($search,$score,$topscore);
    				$before = __('&nbsp;&nbsp;&nbsp;&nbsp; Posted on: ', BSEARCH_LOCAL_NAME);
    				$output .= get_bsearch_date($search,$before);
    				$output .= '</p>';
    				<?php echo get_the_post_thumbnail( $search->ID, $size, $attr ); ?>
    				$output .= '<p>';
    				$output .= get_bsearch_excerpt($search->ID,$bsearch_settings['excerpt_length']);	// This displays the post excerpt / creates it. Replace with $output .= $content; to use content instead of excerpt
    				$output .= '</p>';
    			} //end of foreach loop

    and unfortunately I get an error:

    Parse error: syntax error, unexpected '<' in /Users/Paul/Documents/Websites/balanga.dev/wp-content/plugins/better-search/better-search.php on line 165

    I'm not a coder, but I would love to get your plugin showing small thumbnails with the results. Did I adjust the code wrongly? Could I Beta test the plugin version that you are developing that achieves this?

    Cheers

  4. Ajay
    Member
    Plugin Author

    Posted 8 months ago #

    Instead of the code you used, try:

    $output .= '<span class="bsearch_thumb">'.get_the_post_thumbnail( $search->ID, $size, $attr ).'</span>';
  5. pxjenkins
    Member
    Posted 7 months ago #

    just tried the code...almost working: i get full sized image rather than thumbnail displaying...

    any way to reduce image size so it displays alongside text?

    Thanks!

  6. Ajay
    Member
    Plugin Author

    Posted 7 months ago #

    Try the below code. This should pull just the thumbnail version of the image

    $output .= '<span class="bsearch_thumb">'.get_the_post_thumbnail( $search->ID, 'thumbnail' ).'</span>';
  7. pxjenkins
    Member
    Posted 7 months ago #

    Cheers Ajay - that worked!
    Paul

  8. Ajay
    Member
    Plugin Author

    Posted 7 months ago #

    Glad to know this Paul :)

Reply

You must log in to post.

About this Plugin

About this Topic

Tags