How to integrate WordPress with Google custom search

Source: Internet
Author: User
The following describes only the WordPress integration method. for other systems, see. The following placement method is a typical WordPress application. search columns are placed in the sidebar Widge or the top Banner, and the search results are placed on a separate page. The results are the same as those in rural property management. Key: The search box and the search result are not displayed on the same page. you need to modify the default search box and create a Searc manually.

The following describes only the WordPress integration method. for other systems, see. The following placement method is a typical WordPress application. search columns are placed in the sidebar Widge or the top Banner, and the search results are placed on a separate page. The results are the same as those in rural property management.

Key points:

  • The search box and search result are not displayed on the same page.
  • You need to modify the default search box
  • You need to manually create a Search page to display Search results

The usage is as follows:

1. First, you must log on to the ingress.

2. after the creation is complete, click "appearance" on the left and select "two pages", for example:

3. click "save and get code ".Search boxAndSearch ResultsEnter your Page address in the specified URL to display the Search result. for example, icultivator.com/search. make sure that the address you entered can be properly accessed. (if you refer to this article, you must be able to open the Search Page to be created below ).

4. the code example in the search box is as follows (the content of the form element depends on your website. here, we only use my website as an example ):

《script》    (function() {        var cx = 'your_custom_id';        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》

The above You can also write your own domain name, for example, my website can write: Ghost.

5. search result display page code

This part of the code can be completed by creating a search page. the search result code displayed in the search file is as follows:

 《script》    (function() {        var cx = 'your_custom_id';        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》

6. the final application result is the same as the search box on top of Nongfu Manor and the search result page:

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.