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>