for mp3 songs free download

indiafreemp3.blogspot.com

indiafreemp3.blogspot.com



Free Mp3 Songs Download

Sunday, April 11, 2010

Creating Custom Search Page in Wordpress Blog

In wordpress, there are two types of webpages – “posts” and “pages”. While “posts” are generated dynamically, “pages” are statics and created explicitly. You can create as many “pages” as you want and put them anywhere in your blog’s structure. Few pages I have here includes – about page, contact page, joining DW page, etc.

Apart from these “pages”, I use a special “search page” with extra-level of customization. It is technically outside my wordpress setup. I do not use wordpress built-in search mechanism. Instead I use, Google custom search like many of you. I will explain why I use Google custom search some other time!

For time being, if you notice my search page do not have any sidebar compared to say “contact page”. A simple way to disable sidebar for any post/page is to surround “get_sidebar()” call in theme with if-else block. But for sake of slight performance improvement and few other reasons I prefer maintaining a dedicated search page outside my wordpress setup. But as you can see, it is blended with my theme very-well!

So here is “how-to” guide to create such “search pages” outside wordpress:

  1. Create a page say in root-directory of your blog. Name it something like – search.php. It will have URL like – http://www.devilsworkshop.org/search.php
  2. Next log into AdSense or Google Custom Search Engine, and create a new custom search or update existing search engine.
  3. Just remember to use above URL (step 1) for search result pafe
  4. Then add following code as it is to it:
    define('WP_USE_THEMES', false);
    require('wp-blog-header.php');
    get_header();
    ?>

    get_footer();
    ?>
  5. Finally replace “Google Search Result CODE” line in above code with codes you will get from Google.
  6. Save/Upload search.php in your blog’s root directory.

If you need to use some CSS, use it inline on Google search result code’s first line, i.e.

Example:

I needed to set width attribute like above to expand search results into space made available by absence of sidebar.

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails