


Simple steps to add Google search function to WordPress_javascript skills
There are many articles on the Internet about how to integrate Google Custom Search in WordPress, but few mention how to integrate the v2 code. Today, through actual testing, I will explain to you how to integrate Google Custom Search in WordPress. of.
Get Google Custom Search Code
Enter http://www.google.com/cse/
All series of Google accounts are universal,
So if you have gmail, you can successfully enter this custom search system
After a series of registrations and logins, you will enter the main interface of cse. The Internet speed is sometimes a little painfully slow, so everyone must be patient.
Enter the main interface and click New Search Engine
Fill in the content as shown below:
Check the box to agree to the agreement, then click Next,
Choose the style according to your preference, and a demonstration will appear directly below.
Click Next and the code will appear.
Guys, have you got the code? The code I got is as follows:
<!-- Put the following javascript before the closing </head> tag. --> <script> (function() { var cx = '006739494664361712883:_id_bvfkgey'; var gcse = document.createElement('script'); gcse.type = 'text/javascript'; gcse.async = true; gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//www.google.com/cse/cse.js?cx=' + cx; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(gcse, s); })(); </script> <gcse:searchbox></gcse:searchbox> <!-- Place this tag where you want both of the search box and the search results to render --> //下面这一对标签就是谷歌搜索框要显示的标签, //即,你想把搜索框放哪就把这一对标签放哪。 <gcse:search></gcse:search>
Add search page
Create a new page in your WordPress with the alias search
Assume that a fixed connection is set up and the access address of this page is
http://pangbu.com/google-search-in-wordpress
Use html editing mode and add the code you just obtained to the article.
Want to know what the effect is?
Effect
You can search directly below to try.
System integration
Okay, you already have a search page, now we have to integrate it into WordPress search.
Trouble? Of course it's not troublesome.
Find the file that defines the style of your theme search box,
Usually searchform.php,
Some themes may vary slightly.
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 pretty much the same, I'm sure you can find it.
<form action="http://pangbu.com" method="get"> <input id="searchtxt" class="textfield searchtip" type="text" name="s" size="24" value="">
Change to action="URL of the search page you just created"
Remember to bring http, such as
action="http://pangbu.com/google-search-in-wordpress"
Integrated code examples
My modified topic search style code is as follows
<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="24" value=""> <input type="submit" id="searchbtn" class="button" value="搜索"> </div> </form> </div>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Google AI has started to provide developers with access to extended context windows and cost-saving features, starting with the Gemini 1.5 Pro large language model (LLM). Previously available through a waitlist, the full 2 million token context windo

Google has introduced DisplayPort Alternate Mode with the Pixel 8 series, and it's present on the newly launched Pixel 9 lineup. While it's mainly there to let you mirror the smartphone display with a connected screen, you can also use it for desktop

Google's AI assistant, Gemini, is set to become even more capable, if the APK teardown of the latest update (v15.29.34.29 beta) is to be considered. The tech behemoth's new AI assistant could reportedly get several new extensions. These extensions wi

Google recently responded to the performance concerns about the Tensor G4 of the Pixel 9 line. The company said that the SoC wasn't designed to beat benchmarks. Instead, the team focused on making it perform well in the areas where Google wants the c

The Pixel 9 series is almost here, having been scheduled for an August 13 release. Based on recent rumours, the Pixel 9, Pixel 9 Pro and Pixel 9 Pro XL will mirror the Pixel 8 and Pixel 8 Pro (curr. $749 on Amazon) by starting with 128 GB of storage.

A few months have passed since Android Authority demonstrated a new Android desktop mode that Google had hidden away within Android 14 QPR3 Beta 2.1. Arriving hot on the heels of Google adding DisplayPort Alt Mode support for the Pixel 8 and Pixel 8

Google's AI Test Kitchen, which includes a suite of AI design tools for users to play with, has now opened up to users in well over 100 countries worldwide. This move marks the first time that many around the world will be able to use Imagen 3, Googl

More promotional materials relating to the Pixel 9 series have leaked online. For reference, the new leak arrived shortly after 91mobiles shared multiple images that also showcased the Pixel Buds Pro 2 and Pixel Watch 3 or Pixel Watch 3 XL. This time
