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:
- 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
- Next log into AdSense or Google Custom Search Engine, and create a new custom search or update existing search engine.
- Just remember to use above URL (step 1) for search result pafe
- Then add following code as it is to it:
define('WP_USE_THEMES', false);
require('wp-blog-header.php');
get_header();
?>
get_footer();
?> - Finally replace “Google Search Result CODE” line in above code with codes you will get from Google.
- 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