Add Google search function in WordPress simple steps to explain _javascript skills

Source: Internet
Author: User

Many online writing how to integrate Google's custom search in WordPress article, but very few mention how to integrate the V2 version of the code, today through the actual test to explain to you, how to achieve in WordPress integrated Google custom search.

Get Google Custom Search code
Enter http://www.google.com/cse/
Google's various series of accounts are generic,
So if you have Gmail, you can get into this custom search system.
A series of registration, landing you entered the CSE main interface, network speed sometimes some eggs pain slow, so we have to have patience.
Enter the main interface point new search engine
Fill in the content as shown in the following figure:

Check to agree to the agreement, and then click Next,
Choose the style according to your preference, the following will appear directly to the demo Oh Pro.
Then the next step, the code will appear.
Are you getting the code, dear? The code I obtained is as follows:

<!--put the following JavaScript before the closing  
 

Add Search Page
Create a new page in your WordPress, don't name search.
Suppose a fixed connection is set up, and the access address for this page is
Http://pangbu.com/google-search-in-wordpress
In HTML editing mode, add the code you just obtained in the article.
Want to know what the effect is?

Effect
you can search directly below for a try.


System Integration
Well, you already have the search page, and now we are still poor integration into WordPress search.
Are you in trouble? Of course it's no trouble.
Find the file in your theme search box style definition,
It's usually searchform.php,
Some topics may be slightly different.
There are two more important sentences,
One is the form submission address, action= "XXX"
One is the form parameter name name= "s",
The code here is very similar, I believe you can find.

<form action= "http://pangbu.com" method= "get" > <input id= "searchtxt" class= "TextField searchtip" type= "
Text "name=" s "size=" "value=" ">

Put action= "XXX"
Change to action= "The URL of the search page you just created"
Remember to bring HTTP, like
action= "Http://pangbu.com/google-search-in-wordpress"
Name= "s" changed into Name= "Q"

Consolidating code samples
My theme Search style is modified with the following code

<div id= "SearchBox" style= "Display:block;" >
 <form action= "http://pangbu.com/google-search-in-wordpress" method= "get" >
 <div class= " Scontent Clearfix "> <input type=" text "id=" Searchtxt "class=" TextField searchtip "name="
  Q "size=" "value=" ">
  <input type=" Submit "id=" SEARCHBTN "class=" button "value=" Search ">
 </div>
 </form>
</div>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.