Add Search Functionality to Your Site

Disclosure: We are a professional review site that receives compensation from the companies whose products we review. We test each product thoroughly and give high marks to only the very best. We are independently owned and the opinions expressed here are our own.

0 Flares Filament.io 0 Flares ×

Do you have a search field on your WordPress site? If not, why not add one. Having your own search engine for your site will help your visitors find what they are looking for and keep them on your site longer. By using a search field, visitors can type in a set of keywords and the on-site search engine will list all topics related to the search. Adding a search field to a WordPress site is essential, as your blog grows, and more posts goes into the archives, a blog becomes harder to navigate and older pages get harder to find. Most visitors are not going to search more than a few pages before giving up and moving on. One of the easiest ways to help your visitors out, is to adda search field plugin or turn on your theme’s search field.

My Theme Doesn’t Have Search Field and I Do Not Want to Add a Plugin

Luckily, my Mystique theme by digitalnature came with one, but several of the other sites I maintain and work on daily did not have search fields and the plugins just didn’t cut it. So I decided that I would use my own search field. I just added a simple PHP line and you can put that line on any page, sidebar, header, or footer and it should work.

[sourcecode language=”PHP”] <?php include(TEMPLATEPATH . "/searchform.php"); ?> [/sourcecode]

The code below works with at least 3 themes. If the code does not work on your site it should create a basic search field.

test This is what mine looks like? Results will vary.

Once you have the code in place, you will need to create a search results page, if one was not created by the theme creator. If you do not have a search field provided by your theme, then more than likely you will not have a results page.

How to Create a Search Results Page

1. First thing you need to do is create the search.php file. Open up notepad (windows) or if you want to use something a little more advanced, check out Notepad++ and download the program to edit and create code for your site.

Paste the code below in the document and save it as searchform.php

[sourcecode language=”PHP”]
<?php
/*
Template Name: Search Page
*/
?>
[/sourcecode]

Here is what my searchform.php file opening code looks like.

[sourcecode language=”PHP”]
<?php
/*
Mystique/digitalnature
*/
?>
[/sourcecode]

3. save the file and upload to your theme directory.

4. That should be it. If it doesn’t work, then you might have to create a page and title it ‘Search’ and from the page template drop down menu select the template search page.

NOTE: I have not tested this since I already a search page. After some research, I found that this was the easiest way to make it work. All of my themes came with either a search box and results page or just the results page. Before building the search page, look at your style sheets and make sure you do not have a results pages.

Conclusion

This is just a basic way to create a search box. The results page is basic and you may have to go back and style it to match your site. You may need to add the php code to add the side bars and footers and this will need to be added to the search.php file.  But will address how to build a search result page in the future.

Let me know if this works, if it didn’t or I mess up on the code.

EvolutionaryDesigns.net runs on the Genesis Framework

Genesis Framework

Genesis empowers you to quickly and easily build incredible websites with WordPress. Whether you're a novice or advanced developer, Genesis provides the secure and search-engine-optimized foundation that takes WordPress to places you never thought it could go. It's that simple - start using Genesis now!


Take advantage of the 6 default layout options, comprehensive SEO settings, rock-solid security, flexible theme options, cool custom widgets, custom design hooks, and a huge selection of child themes ("skins") that make your site look the way you want it to. With automatic theme updates and world-class support included, Genesis is the smart choice for your WordPress website or blog.

About James

James spends most of his free time using social media and loves to teach others about design, web development, CSS, SEO, and social media. He is addicted to Wordpress, social media, and technology. You can reach him on his, personal website, Do not forget to follow him on Twitter @element321

Comments

  1. Thanks for sharing, James.
    This is great but I still prefer using Google search for my site, do you know how to add Search Results Page to our site?

Trackbacks

  1. Element321 says:

    New Blog Post: Add Search Functionality to Your Site http://bit.ly/9fB3Ln #wordpress #php

  2. RT @element321: Add Search Functionality to Your Site http://bit.ly/9fB3Ln

  3. […] This post was mentioned on Twitter by Omer Greenwald, Element321. Element321 said: New Blog Post: Add Search Functionality to Your Site http://bit.ly/9fB3Ln #wordpress #php […]

  4. Learn How to Add Search Functionality to Your WordPress Site…

    Do you have a search field on your WordPress site? Learn how yo can easily add one to your WordPress Blog without having to use a plugin….

  5. Story added…

    Your story was featured in Featured in MMO Social Network! Here is the link to vote it up and promote it: http://www.mmosocialnetwork.com/Wordpress/Learn_How_You_Can_Easily_Add_a_Search_Box_to_WordPress

  6. Famous Bloggers says:

    Add Search Functionality to Your Site http://bit.ly/9fB3Ln by @element321:

  7. Add Search Functionality to Your Site http://bit.ly/9fB3Ln by @element321:

  8. Element321 says:

    RT @element321: Add Search Functionality to Your Site http://bit.ly/9fB3Ln

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Flares Twitter 0 Facebook 0 Pin It Share 0 Buffer 0 Email -- Filament.io 0 Flares ×
%d bloggers like this: