Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
Coppa WPB
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Come aggiungere la ricerca Google in un sito WordPress (in modo semplice)

Per default, WordPress è dotato di una caratteristica di ricerca integrata, ma non è molto buona. Tuttavia, è possibile cambiare facilmente la situazione aggiungendo Google Search al suo posto per fornire risultati più pertinenti e accurati.

Questo migliorerà l’esperienza dell’utente sul blog e renderà più facile per i visitatori trovare i contenuti che stanno cercando.

In questo articolo vi mostreremo come aggiungere facilmente Google Search a un sito WordPress.

Add Google Search in a WordPress Site

Perché si dovrebbe usare la ricerca di Google in WordPress?

La funzione di ricerca predefinita di WordPress non è molto utile e spesso non riesce a trovare risultati pertinenti alle richieste degli utenti. Questo costringe molti proprietari di siti a cercare delle alternative.

È possibile utilizzare un popolare plugin di ricerca per WordPress. Tuttavia, il problema è che dovrete comunque gestire il plugin e questo avrà un impatto sulle risorse del vostro server.

D’altra parte, è possibile utilizzare l’affidabile e potente funzione di ricerca di Google. È gratuita, consente di limitare la ricerca solo ai vostri siti e può essere eseguita dal vostro sito WordPress.

Inoltre, la ricerca su Google è veloce, gli utenti si fidano già del marchio e voi non dovrete occuparvi della manutenzione o dell’aggiornamento. Se necessario, potete anche consentire agli utenti di cercare siti web esterni su Google.

Detto questo, vediamo come aggiungere facilmente una ricerca per siti Google al vostro sito WordPress.

Video tutorial

Subscribe to WPBeginner

Se preferite le istruzioni scritte, continuate a leggere.

Come aggiungere la ricerca di Google a un sito WordPress

Potete aggiungere facilmente Google Search al vostro sito WordPress visitando il sito web del motore di ricerca programmabile di Google.

Da qui, fare clic sul pulsante “Inizia”.

Click the get started button on the Programmable Search Engine page

In questo modo si accede alla pagina “Crea un nuovo motore di ricerca”, dove è necessario aggiungere un nome al modulo di ricerca che si sta per creare.

Quindi, selezionate l’opzione “Cerca siti o pagine specifiche” nella sezione “Cosa cercare?” e aggiungete l’URL del vostro sito WordPress.

Ora, Googe Site Search indicizzerà solo i contenuti disponibili sul vostro sito web. Tuttavia, se si desidera che Google mostri anche i risultati di ricerca di altri siti web, è possibile scegliere l’opzione “Cerca nell’intero web”.

Add website URL to create Google Site search

Quindi, scorrete verso il basso e attivate l’opzione “Ricerca per immagini” per consentire al modulo di ricerca di Google di indicizzare le immagini sul vostro sito web. Consigliamo questa opzione se vendete foto online, avete un sito web di fotografia o gestite un blog di viaggi.

Successivamente, è possibile attivare l’interruttore “Ricerca sicura”, in modo che agli utenti non vengano mostrati risultati inappropriati per le loro ricerche.

Una volta terminato, fare clic sul pulsante “Crea”.

Click create to generate a google search engine ID

Google genererà ora il codice ID del motore di ricerca per voi.

Da qui, è sufficiente copiare il codice e incollarlo in un’applicazione Notepad o in un editor di testo.

Copy the Google Search Engine ID from the website

Ora è necessario visitare la dashboard di WordPress e modificare i file del tema per aggiungere la ricerca al <body> del sito. Tuttavia, questa operazione può essere rischiosa e il più piccolo errore può distruggere il vostro sito web.

Per questo motivo vi consigliamo di utilizzare WPCode. È il miglior plugin per gli snippet di codice di WordPress sul mercato che rende sicura e facile l’aggiunta di codice personalizzato.

Per prima cosa, è necessario installare e attivare il plugin WPCode. Per istruzioni dettagliate, consultare la nostra guida per principianti su come installare un plugin di WordPress.

Nota: WPCode ha un piano gratuito che potete utilizzare per questa esercitazione. Tuttavia, l’aggiornamento alla versione pro vi darà accesso a ulteriori funzionalità, come la logica condizionale intelligente, una libreria cloud di frammenti di codice e altro ancora.

Dopo l’attivazione, visitare la pagina Code Snippets ” + Add Snippet dalla barra laterale dell’amministrazione di WordPress. Qui, fare clic sul pulsante “Usa snippet” sotto l’opzione “Aggiungi il tuo codice personalizzato (nuovo snippet)”.

Add new snippet

Si aprirà la pagina “Crea snippet personalizzato”, dove si potrà digitare un nome a piacere per lo snippet. Quindi, selezionare ‘Universal Snippet’ come tipo di codice dal menu a discesa sulla destra.

Una volta fatto ciò, è sufficiente incollare l’ID del motore di ricerca Google nella casella “Anteprima codice”.

Paste the Google Search Engine ID into WPCode preview box

Quindi, scorrere giù fino alla sezione “Pannello di inserimento” e selezionare la modalità “Inserimento automatico”. Dopo l’attivazione, il modulo di Google Search verrà automaticamente aggiunto al sito.

Successivamente, è possibile espandere il menu a discesa “Posizione” per scegliere dove visualizzare la casella di ricerca.

Ad esempio, se si desidera visualizzare il modulo di ricerca nella parte superiore di tutte le pagine e i post, è possibile selezionare l’opzione “Inserisci prima del post”.

Choose location and insertion for the search engine ID

Quindi, scorrere indietro fino alla parte superiore e spostare l’interruttore “Inattivo” su “Attivo”.

Infine, fare clic sul pulsante “Salva frammento” per memorizzare le impostazioni.

Save Google Search Engine ID snippet

È stato aggiunto manualmente un modulo di ricerca di Google Site.

Ora potete visitare il vostro blog WordPress per vederlo in azione.

Google Search preview

Alternativa: Utilizzare SearchWP per creare un fantastico modulo di ricerca

Se trovate difficile aggiungere Google Site Search al vostro sito web o state cercando un’alternativa, potete usare SearchWP per la ricerca interna.

È il miglior plugin di ricerca per WordPress sul mercato che sostituisce automaticamente il modulo di ricerca predefinito e consente agli utenti di trovare tutto ciò di cui hanno bisogno sul vostro sito.

The SearchWP homepage

SearchWP è utilizzato da oltre 30.000 siti web e consente di creare una scala di rilevanza personalizzata per regolare l’algoritmo di ricerca.

È inoltre possibile rendere ricercabile qualsiasi parte del sito, compresi PDF, post type / tipi di contenuto personalizzati, media, commenti, campi personalizzati, prodotti WooCommerce e altro ancora.

Se avete un sito multilingue, potete anche creare una ricerca multilingue con il plugin.

Configure SearchWP engine settings

Tuttavia, è necessario tenere presente che, a differenza di Google Search, il plugin può indicizzare e mostrare risultati solo per i contenuti disponibili sul vostro sito web.

Per maggiori dettagli, potete consultare il nostro tutorial su come migliorare la ricerca su WordPress con SearchWP.

Speriamo che questo articolo vi abbia aiutato a capire come aggiungere facilmente Google Search a un sito WordPress. Potreste anche consultare la nostra guida per principianti su come add-on la capacità di ricerca vocale al vostro sito WordPress e il nostro tutorial su come rendere i commenti dei blog ricercabili in WordPress.

Se questo articolo vi è piaciuto, iscrivetevi al nostro canale YouTube per le esercitazioni video su WordPress. Potete trovarci anche su Twitter e Facebook.

Divulgazione: I nostri contenuti sono sostenuti dai lettori. Ciò significa che se cliccate su alcuni dei nostri link, potremmo guadagnare una commissione. Vedi come WPBeginner è finanziato , perché è importante e come puoi sostenerci. Ecco il nostro processo editoriale .

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Il kit di strumenti WordPress definitivo

Ottenete l'accesso gratuito al nostro kit di strumenti - una raccolta di prodotti e risorse relative a WordPress che ogni professionista dovrebbe avere!

Reader Interactions

84 commentiLascia una risposta

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Ruhul Mashbu says

    When I insert the google engine id the plugin automatically creates a page where the search result will be displayed. But what I need is to change the link of the page where the search result will be displayed. How can I do that?

  3. Yohan Perera says

    I am using the WP Google Search Plugin. I was so frustrated because I couldn’t get the search icon show. Your tip on customizing the search box through the dashboard in Google Custom Search solved the problem.

  4. Graham FB says

    Cool artricle but what I wanted to have a the custom search box in the centre of a blank page as if it was a google search page. I found the plugin Blank Slate which gives the blank page just not sure how to either center and limit the width of the search box either by code or shortcode any ideas ??

  5. Saurabh Saneja says

    Thanks wpbeginner your articles have always helped me a lot. I wanted to do it manually because that way wherever I have search form it’ll be replace by custom google search and your article did work for me as always :)

    When i tried it first it didn’t work because I registered website as http(s) or didn’t enclose the code within a div so it really gave e a hard time. Anyway i am all thanks for your help!!

    Thanks again :)

  6. Craig says

    It works exactly how I want it to, searching 2 different web sites, as long as I am logged into WP Admin. Once I’m no longer logged in to the WP Admin I get

    Not Found
    Apologies, but the page you requested could not be found. Perhaps searching will help.

    What step did I miss?

    • Dibyandu Pal says

      I don’t have much idea about web designing and further customizing. I am learning wordpress blogging from last 5 months, and I think it may be due to a problem while publishing your search result page. There is a visibility option in edit page mode. If that page is private or password protected, this problem you said may arise. If it is done so, make it public..

  7. Shri says

    Plugin method works well for me. But I am trying to replace theme’s native menu bar search functionality with CSE. Its wordpress native search only. So manual editing searchform.php method should work for me.
    But after editing searchform.php my search widget vanishes from sidebar. I am using Colormag theme by themegrill.
    Looking out for a help.

    I am also keen to see mentioned in above comment but this site is offline now. I tried to fetch it from wayback machine but couldn’t found in its past impressions.

    • Dana says

      The same thing happens to me when I paste that code into searchform.php. Not sure this is proper as searchform.php by default is an HTML form. The code copied from Custom Google Search is a JavaScript tag…. should this even work??

  8. Waleed Younas says

    Really Helpful topic as always.

    I am using a Plugin in my Site. How can I exclude ads from Search Results

  9. Jackson says

    Hi Wpbeginner,

    This worked like charm! The manual method is just as awesome as you wrote. Google custom search now showing on my site!

    Thank you so much.

  10. Claire Brotherton says

    Can you only implement custom search when the site is live and indexed by Google? If it’s hidden or password protected, can it be added then?

  11. Susanna says

    I am trying to add Google Search with the Plugin to my website. I got as far as the step where I am supposed to paste the search engine ID into the WP Google Search’s settings page. My settings page does not seem to have any place where I can do this. Can you tell me where the ID should be pasted and what it is called?

    Thanks.

  12. fdecicco says

    the manual way of doing this is poorly described and a total waste of time. If you gonna do something do it right ir dont do it at all.

    • WPBeginner Support says

      If you are having difficulty using the manual method, then please try the first method. It is easier to add Google Search with the help of a plugin. If you need to do it manually, then please let us know which part isn’t clear and we will try to explain it here.

      Admin

      • saajan bedi says

        Manually Adding Google Search doesn’t work (I’m using colormag theme), U need to Update the article

  13. phil davis says

    By using this search plug-in will I be able to see a report on what words were typed in the box to search for?

    I want to know what people are searching for, so I can create content based on their search.

  14. Ameer Shaik says

    I have updated through plugin method. Only search button is not displayed properly. Please suggest(The text “Search” is moved down, only top portion is visible). Pl suggest

  15. Jennifer says

    Another awesome tutorial – I didn’t even know it was possible to use Google Search like this! I’ve now got this running on my website, thanks so much!

  16. Imran Khan says

    Nice post, very helpful as well as easily understandable. I have also created my custom search bar by following your steps. Thanks for sharing this great post with us.

  17. Angelo says

    Hi!

    Do we have to choose among among the 5 font options available or we can import a font we like better?

  18. Eric Kazda says

    Can somebody tell me why this is a more beneficial search than using the standard WordPress search form? Are there SEO implications? I’m just not sure why anyone would use this over the standard search.

    • Adam Connell says

      I generally find that whenever I search a website for a topic, and it’s using WordPress default search – I’ll get VERY poor results.

      They’ll lack relevance.

      By using Google’s custom search, you won’t get any SEO benefits but your readers will find it easier to get what they’re looking for.

  19. Priti says

    In “Search by Google” how to we specify the our google search id ? In widget don’t we have to keep the google search engine id?

  20. Carol Long says

    Hi – can you tel me please how to remove this? I have just seen it appear on all my pages and I don’t want it at all!

    Many thanks

  21. Richard Bishop says

    Hello, and thank you for creating this post and video. I really found it to be helpful in terms of providing better search results for my site WarCraft Press.

    I would however say that you should have pointed out at the beginning of the lesson there are 2 ways to accomplish this task. I did it once with out the plugin then later realized there was a plugin for it.

    That said thanks again for a great lesson and I certainly look forward to future lessons!

    Kombear
    WarCraft Press

  22. cowboy Mike says

    Howdy,
    I have seen you recommend editing wp files and wp theme template files like you have in this article for the searchform.php file.

    My concern is when there is a theme update or wordpress update wouldnt the changes to the searchform.php suggested here be lost after for example a theme update?

    Happy trails, Mike

  23. Shahadat Hossain says

    can i use google custom search box and wp normal box all together in my site. or i will have to use only one search box between two of this search box

  24. Nasser says

    How to make a search bar that join to google? Not just a small windows as Custom google search. Exactly work as google search.
    Thanks.

  25. Ramesh Tatipigari says

    Hi ,

    I want to add google search bar to every post of my wordpress site or i want to add google search bar to below main menu could you please help me regarding this.

  26. Javed Ahmadzai says

    Well, I have done the same procedure. my theme does not contain searchform.php i created it but it contain searchresults.php i think its theme’s search. but after creating the searchform.php and pasting the code there. another search widget not appeared. Only sahifa search which is theme’s so please can you tell me what the problem. :(

  27. Raghu says

    Hi, I would like to know if I can use google custom search for my intranet portal. I have setup wikipedia for internal purpose and I would like to integrate google custom search for this, however I am not getting result when I integrate.
    So the question is: Is google custom search meant only for public websites?

  28. Chris says

    Hi, I went through these steps exactly for my WordPress site, but the search box doesn’t appear anywhere. There are no .js errors in the console. I put a border around the containing div and the border appears, but there’s nothing inside it. I pasted the code I generated from Google inside searchform.php. As a test I also tried pasting the google code on a test page, but still no luck.

    Any ideas on troubleshooting?

  29. Deepak Singh says

    Can you please guide me how we cana dd Custom Search in genesis child theme. I tried many tutorials but none of them work.

  30. Joy Baker says

    Forgive my newbie status, but when pasting the code into the search.php of my theme’s search page, do I replace the code in the page with Google’s code? I am an idiot when it comes to php code. I know what it looks like, what the opening/closing tags look like, but I have no idea what you mean when you say paste the code in the page.

    Where? Replace it all or between the opening/closing tags or… ???

    Current code looks like this:


    So, do I replace the entire code in the page with the custom Google Search I’ve created?
    Google code:


    Thanks for any help you can give.

  31. David Trees says

    Thanks for a very well written article. It is easy to read and follow,even for a complete newbie.

    The only thing I don’t get, is how to do this;

    “If your theme does not have a searchform.php file, then you need to create one using a text editor like Notepad and upload it to your theme directory using FTP client”

    Remembering I am a newby. I did instal my WP site to my shared hosting by following clear instructions, using FTP. So I guess I am saying how does one create the searchform.php file?

    Thanks again.

    • WPBeginner Support says

      Open your FTP client and connect to your shared hosting site. Navigate to /wp-content/themes/ directory. Click on the theme you are using. For example if you are using twentytwelve theme you will see a directory twentytwelve there, open it. Once you have opened your theme directory in your FTP client, right click and select ‘Create new file’. A new dialog box will appear enter searchform.php as the file name. That’s all you have created searchform.php file.

      You can also create this file on your computer by opening a plain text editor like notepad and save file as searchform.php, after creating the file you can upload it to your theme directory using an FTP client.

      You can edit this file from inside your WordPress Admin area. Go to Appearance » Editor and click on searchform.php file from the list of files on the right.

      Admin

      • Patricia says

        I tried to do just that but something else happened. The search box disappeared and was replaced by an ad. The widgets below the search widget area in my primary sidebar also disappeared. I’ll figure this out soon. It’s a pretty nifty feature.

  32. Abhisek says

    This is a very simple and easy to digest. But, if anyone want to use his/her theme’s default search bar and display the search results then how will he integrate google cse with his theme’s search, I found a great and simple method, it just requires editing your search.php file of your theme, just replace the php statement that is responsible for showing the search results. Feel free to read the full post at my blog :

Lascia una risposta

Grazie per aver scelto di lasciare un commento. Tenga presente che tutti i commenti sono moderati in base alle nostre politica dei commenti e il suo indirizzo e-mail NON sarà pubblicato. Si prega di NON utilizzare parole chiave nel campo del nome. Avremo una conversazione personale e significativa.