Improving WordPress Search

March 9th, 2010

Product search on Worm Sign T-Shirts using plugins to improve WordPress default searchThe default search on WordPress wasn’t going to be suitable for the product search I wanted to implement on Worm Sign T-Shirts. On the default theme, standard search will give you a results page that contains the pages and posts that were found as a clickable title and excerpt – a text only sample of the the pages content. This wasn’t going to good enough for a T-Shirt store.

Using 2 plugins I was able to define the pages and posts I wanted to be included in the search, as well as pages and posts that I didn’t want to be included, and to include an image from the product page as the main focus of the search results.

Search Unleashed gives you options for what content is searched. Rather than stating what could be searched, I selected what was to be excluded from the search results; all posts from the blog, as well as Home, FAQ’s and Contact page – this just left the T-Shirt pages, giving me a product search. Although one that would just give me the text from the pages and no images, not quite there yet.

Get The Image scans a page or post with the WordPress loop and extracts an image – the plugin has a number of options for styling, as well as options for what image to grab from the post; one that is automatically extracted, or one decided by a custom field. Here’s the code that sits inside the loop;

<div id=wsthumbnail”>
<a href="<?php the_permalink() ?>">
<?php get_the_image( array( ‘image_scan’ => true ) ); ?></a><br>
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
</div>

The options for Get The Image plugin sit in an array, you can add as many or as few as you want. I’ve just simply added an image scan to pull the first image it finds from the page, the image is already the correct size for the results page and will be styled within it’s containing div layer.

Tags: , , , , ,

Post a Comment