• Resolved gerardog2000

    (@gerardog2000)


    I have tried many different ways of replacing my current search with google custom search but no matter what, it does not seem to work. I believe that it has to do with how I am naming the search results page. Does anybody know how I can find out what is the address for my search results page? Or does anybody else have any idea on what I am doing wrong? I tried replacing the searchfrom.php code on my site, with the code that I got from google for the “google custom search box”. I also replaced the code for search.php from my site with the code given to me by google for “google search results.” Below are the original code snippets from my site for search box and the search results page. If anybody could help me get this right, I would really appreciate it. I created a custom template from instructions from another site, and this is working but the page is not being displayed correctly. I would appreciate any help whether you can give me help with the original coding(listed below) or with the current coding

    Searchform.php

    <?php $search_text = empty($_GET['s']) ? "Search" : get_search_query(); ?>
    <div id="search">
        <form method="get" id="searchform" action="<?php bloginfo('home'); ?>/">
            <input type="text" value="<?php echo $search_text; ?>"
                name="s" id="s"  onblur="if (this.value == '')  {this.value = '<?php echo $search_text; ?>';}"
                onfocus="if (this.value == '<?php echo $search_text; ?>') {this.value = '';}" />
            <input type="image" src="<?php bloginfo('template_url'); ?>/images/search.gif" style="border:0; vertical-align: top;" />
        </form>
    </div>

    and this is my search.php

    <?php get_header(); ?>
    <div class="span-24" id="contentwrap">
        <div class="span-16">
            <div id="content">
    
        <?php if (have_posts()) : ?>
    
            <h2 class="pagetitle">Search Results</h2>
    
            <?php while (have_posts()) : the_post(); ?>
    
                <div <?php post_class() ?>>
                    <div class="postdate"><?php the_time('F jS, Y') ?></div>
                    <h2 class="title" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
                    <div class="entry">
    <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) { the_post_thumbnail(array(200,160), array("class" => "alignleft post_thumbnail")); } ?>
                        <?php the_excerpt() ?>
                    </div>
                </div>
    
            <?php endwhile; ?>
    
            <div class="navigation">
                <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?>
                <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
                <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
                <?php } ?>
            </div>
    
        <?php else : ?>
    
            <h2 class="pagetitle">No posts found. Try a different search?</h2>
    
        <?php endif; ?>
    
            </div>
        </div>
    
    <?php get_sidebars(); ?>
    </div>
    <?php get_footer(); ?>

    my site is http://www.techcorner.com.

    Thanks again.

Viewing 1 replies (of 1 total)
  • Thread Starter gerardog2000

    (@gerardog2000)

    Ok, I think that I know what the problem is with my new search page. The problem is that the page template is for a different theme. Anybody have any ideas as to where I would enter the google code in the code listed above so that the page will display correctly?

Viewing 1 replies (of 1 total)
  • The topic ‘How do I add Google Custom Search to my site’ is closed to new replies.