• Hello there,

    I’m trying to embed Google’s custom search engine (CSE) on my WordPress site…even better, swap out the WordPress search box with the Google search element. I am able to embed Google’s form code successfully in my sidebar.php code and somewhat successfully in my searchform.php file, but I want the search results to display in the body of my website…not a target=”blank” solution…or the <div> code that Google gives you to place in your HTML. I guess the functionality that I’m after is exactly like what you already see with a WordPress search, I just don’t want WordPress results.

    I don’t know enough about PHP to solve my own problems at this point.

    Here is the code from Google, which has been modified a little:

    <form id=”searchform” action=”http://www.google.com/cse”&gt;
    <label for=”s” class=”assistive-text”><?php _e( ‘Search’, ‘twentyeleven’ ); ?></label>
    <input type=”hidden” name=”cx” value=”partner-pub-xxxx” />
    <input type=”hidden” name=”ie” value=”UTF-8″ />
    <input type=”text” class=”field” name=”q” id=”s” placeholder=”<?php esc_attr_e( ‘Search’, ‘twentyeleven’ ); ?>” />
    <input type=”submit” class=”submit” name=”sa” id=”searchsubmit” value=”<?php esc_attr_e( ‘Search’, ‘twentyeleven’ ); ?>” />
    </form>
    <script type=”text/javascript” src=”http://www.google.com/coop/cse/brand?form=searchform&lang=en”></script&gt;

    I think this (action=”http://www.google.com/cse&#8221;) needs to be specific to my search.php code, but I don’t understand what this (action=”<?php echo esc_url( home_url( ‘/’ ) ); ?>”) is doing…and maybe method=”get” needs to go back in there.

    Thanks for your help.

  • The topic ‘Embedding Google Custom Search Engine: Return Results on Search.php’ is closed to new replies.