Google search
-
in this website https://afpakwar.com/blog/
i replaced the default search with google search by firs adding this code to the search formCode:
<form action=”https://afpakwar.com/blog/search.php” id=”cse-search-box”>
<div>
<input type=”hidden” name=”cx” value=”002223992351000239049:i2jkdqzjvga” />
<input type=”hidden” name=”cof” value=”FORID:10″ />
<input type=”hidden” name=”ie” value=”UTF-8″ />
<input type=”text” name=”q” size=”18″ />
<input type=”submit” name=”sa” value=”Search” />
</div>
</form><script type=”text/javascript” src=”https://www.google.com/jsapi”></script>
<script type=”text/javascript”>google.load(“elements”, “1”, {packages: “transliteration”});</script>
<script type=”text/javascript” src=”https://www.google.com/coop/cse/t13n?form=cse-search-box&t13n_langs=en”></script><script type=”text/javascript” src=”https://www.google.com/coop/cse/brand?form=cse-search-box&lang=en”></script>
and creating a page template called the search template with this code
Code:<?php get_header(); ?>
<?php get_sidebar(); ?><?php
/*
Template Name: Search Template
Description: A template for the search page
*/
?><div id=”cse-search-results”></div>
<script type=”text/javascript”>
var googleSearchIframeName = “cse-search-results”;
var googleSearchFormName = “cse-search-box”;
var googleSearchFrameWidth = 600;
var googleSearchDomain = “www.google.com”;
var googleSearchPath = “/cse”;
</script>
<script type=”text/javascript” src=”https://www.google.com/afsonline/show_afs_search.js”></script><?php get_footer(); ?>
then i made a page with the search template as template and the path https://afpakwar.com/blog/search
this worked fine and after a little modification i got a page like my other website pages with header footer and side bar
now the problem with this is that now on the side bar’s pages section i had 3 links, home , about, and a useless search link
i wanted to remove this so i tried to make the search page invisible.
finally i have arrived at this solution
i have a search.php in /blog/ of my website with the code in the search template minus the
Code:
<?php
/*
Template Name: Search Template
Description: A template for the search page
*/
?>this dosent work quite right in the sence that the
<?php get_header(); ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>do not work and this error is dispayed
Fatal error: Call to undefined function get_header() in /home/afpakwar/public_html/blog/search.php on line 1
by removing these lines however it lookes very ugly
now i could som1 tell me the correct way to get the header footer and sidbar displayed on this page
Reply With Quote
- The topic ‘Google search’ is closed to new replies.