Voulez-vous utiliser la recherche Google sur votre site WordPress ?
Par défaut, WordPress dispose d’une fonctionnalité de recherche intégrée, mais elle n’est pas très performante. En ajoutant Google Ads à sa place, vous pouvez afficher des résultats de recherche plus précis et plus pertinents pour les internautes.
Dans cet article, nous allons vous afficher comment ajouter facilement Google Search à un site WordPress.
![Add Google Search in a WordPress Site Add Google Search in a WordPress Site](https://www.wpbeginner.com/wp-content/uploads/2016/04/add-google-search-in-wordpress-site-og.png)
Pourquoi utiliser la recherche Google dans WordPress ?
La fonctionnalité de recherche par défaut de WordPress n’est pas très utile et ne trouve souvent pas de résultats pertinents aux requêtes des comptes. Cela oblige de nombreux propriétaires de sites à chercher d’autres solutions.
Vous pouvez utiliser une extension de recherche WordPress très répandue. Cependant, le problème est que vous devez toujours gérer cette extension, et cela aura un impact sur les ressources de votre serveur.
En revanche, vous pouvez utiliser la fonctionnalité de recherche fiable et puissante de Google avant. Elle est gratuite, vous permet de limiter la recherche uniquement à vos sites et peut être exécutée à partir de votre site WordPress.
De plus, la recherche sur Google est rapide, les utilisateurs/utilisatrices font déjà confiance à la marque, et vous n’aurez pas à l’entretenir ou à la mettre à jour. Vous pouvez même permettre aux utilisateurs/utilisatrices de rechercher des sites externes sur Google si nécessaire.
Ceci étant dit, voyons comment vous pouvez facilement ajouter une recherche de site Google à votre site WordPress.
Tutoriel vidéo
Si vous préférez des instructions écrites, continuez à lire.
Comment ajouter la recherche Google à un site WordPress
Vous pouvez facilement ajouter la recherche Google à votre site WordPress en visitant le site du moteur de recherche programmable de Google.
Cliquez ensuite sur le bouton « Premiers pas ».
![Click the get started button on the Programmable Search Engine page Click the get started button on the Programmable Search Engine page](https://www.wpbeginner.com/wp-content/uploads/2016/04/click-get-started.jpg)
Vous accéderez à la page « Créer un nouveau moteur de recherche », où vous devrez donner un nom au formulaire de recherche que vous êtes sur le point de créer.
Sélectionné ensuite l’option « Rechercher des sites ou des pages spécifiques » dans la section « Que rechercher ? » et ajouté l’URL de votre site WordPress.
Désormais, la recherche de site Google indexera uniquement le contenu disponible sur votre site. Toutefois, si vous souhaitez que Google affiche également des résultats de recherche provenant d’autres sites, vous pouvez choisir l’option « Rechercher sur l’ensemble du web ».
![Add website URL to create Google Site search Add website URL to create Google Site search](https://www.wpbeginner.com/wp-content/uploads/2016/04/add-website-url.png)
Ensuite, défilez vers le bas et activez l’option « Recherche d’images » pour permettre à votre formulaire de recherche Google d’indexer les images de votre site. Nous vous recommandons cette option si vous vendez des photos en ligne, si vous avez un site de photographie ou si vous tenez un blog de voyage.
Ensuite, vous pouvez également permuter le bouton « Recherche sécurisée » afin que les utilisateurs/utilisatrices n’affichent pas de résultats inappropriés pour leurs requêtes.
Une fois que vous avez terminé, cliquez sur le bouton « Créer ».
![Click create to generate a google search engine ID Click create to generate a google search engine ID](https://www.wpbeginner.com/wp-content/uploads/2016/04/click-create.png)
Google va maintenant générer pour vous le code ID de votre moteur de recherche.
À partir de là, il suffit de copier le code et de le coller dans une application du bloc-notes ou dans un éditeur/éditrices de texte.
![Copy the Google Search Engine ID from the website Copy the Google Search Engine ID from the website](https://www.wpbeginner.com/wp-content/uploads/2016/04/copy-google-search-engine-id.png)
Maintenant, vous devez vous rendre dans votre Tableau de bord WordPress et modifier les fichiers de votre thème pour ajouter la recherche au <body> de votre site. Cependant, cette opération peut s’avérer risquée, et la moindre erreur peut briser votre site.
C’est pourquoi nous vous recommandons d’utiliser WPCode à la place. C’est la meilleure extension d’extraits de code WordPress sur le marché qui rend l’ajout de code personnalisé sûr et facile.
Tout d’abord, vous devez installer et activer l’extension WPCode. Pour des instructions détaillées, consultez notre guide du débutant sur l’installation d’une extension WordPress.
Note: WPCode dispose d’une offre gratuite que vous pouvez utiliser pour ce tutoriel. Cependant, passer à la version pro vous donnera accès à plus de fonctionnalités comme la logique conditionnelle intelligente, une bibliothèque cloud d’extraits de code, et plus encore.
Une fois activé, visitez la page Extraits de code » + Ajouter un extrait à partir de la colonne latérale de l’administrateur WordPress. Ici, cliquez sur le bouton » Utiliser l’extrait » sous l’option » Ajouter votre code personnalisé (nouvel extrait) « .
![Add new snippet Add new snippet](https://www.wpbeginner.com/wp-content/uploads/2010/09/addnewsnippet.png)
Vous accéderez à la page « Créer un extrait personnalisé », où vous pourrez saisir le nom de votre choix pour l’extrait. Sélectionnez ensuite « Extrait de code universel » comme type de code dans le menu déroulant de droite.
Une fois cela fait, il suffit de coller l’ID du moteur de recherche de Google dans la case « Prévisualisation du code ».
![Paste the Google Search Engine ID into WPCode preview box Paste the Google Search Engine ID into WPCode preview box](https://www.wpbeginner.com/wp-content/uploads/2016/04/paste-google-search-engine-id-in-wpcode.png)
Défilez ensuite jusqu’à la section « Insertion » et sélectionnez le mode « Insertion automatique ». Le formulaire de recherche Google sera automatiquement ajouté à votre site dès qu’il sera activé.
Ensuite, vous pouvez déplier le menu déroulant « Emplacement » pour choisir l’endroit où vous souhaitez afficher votre boîte de recherche.
Par exemple, si vous souhaitez afficher le formulaire de recherche en haut de toutes vos pages et publications, vous pouvez sélectionner l’option « Insérer avant la publication ».
![Choose location and insertion for the search engine ID Choose location and insertion for the search engine ID](https://www.wpbeginner.com/wp-content/uploads/2016/04/choose-location-and-insertion-for-searchengine-id.png)
Ensuite, défilez vers le haut et permutez le commutateur « Inactif » en « Actif ».
Enfin, cliquez sur le bouton « Enregistrer l’extrait » pour stocker vos réglages.
![Save Google Search Engine ID snippet Save Google Search Engine ID snippet](https://www.wpbeginner.com/wp-content/uploads/2016/04/save-search-engine-id-snippet.png)
Vous avez bien ajouté un formulaire de recherche Google Site manuellement.
Vous pouvez maintenant visiter votre blog WordPress pour le voir en action.
![Google Search preview Google Search preview](https://www.wpbeginner.com/wp-content/uploads/2016/04/google-search-preview.jpg)
Alternative : Utiliser SearchWP pour créer un formulaire de recherche étonnant
Si vous trouvez difficile d’ajouter Google Site Search à votre site ou si vous recherchez une alternative, vous pouvez utiliser SearchWP pour la recherche interne.
C’est la meilleure extension de recherche WordPress sur le marché qui remplace automatiquement le formulaire de recherche par défaut et permet aux utilisateurs/utilisatrices de trouver tout ce dont ils ont besoin sur votre site.
![The SearchWP homepage The SearchWP homepage](https://www.wpbeginner.com/wp-content/uploads/2021/08/searchwp-min.png)
SearchWP est utilisé par plus de 30 000 sites web et vous permet de créer une échelle de pertinence personnalisée pour ajuster l’algorithme de recherche.
Vous pouvez également rendre n’importe quelle partie de votre site consultable, y compris les PDF, les types de publication personnalisés, les médias, les commentaires, les champs personnalisés, les produits WooCommerce, et bien plus encore.
Si vous avez un site multilingue, alors vous pouvez également créer une recherche multilingue avec l’extension.
![Configure SearchWP engine settings Configure SearchWP engine settings](https://www.wpbeginner.com/wp-content/uploads/2023/03/configure-search-wp-engine-settings.png)
Cependant, vous devez garder à l’esprit que, contrairement à Google Search, l’extension peut uniquement indexer et afficher des résultats pour le contenu disponible sur votre site.
Pour plus de détails, vous pouvez consulter notre tutoriel sur l’amélioration de la recherche sur WordPress avec SearchWP.
Nous espérons que cet article vous a aidé à apprendre comment ajouter facilement Google Search à un site WordPress. Vous pouvez également rechercher notre guide du débutant sur la façon de référencer mon site WordPress sur Google et nos astuces pour utiliser Google Search Console afin d’augmenter le trafic de votre site.
Si vous avez aimé cet article, veuillez alors vous abonner à notre chaîne YouTube pour obtenir des tutoriels vidéo sur WordPress. Vous pouvez également nous trouver sur Twitter et Facebook.
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!
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?
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.
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 ??
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![:)](https://www.wpbeginner.com/fr/wp-content/plugins/classic-smilies/img/icon_smile.gif)
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![:)](https://www.wpbeginner.com/fr/wp-content/plugins/classic-smilies/img/icon_smile.gif)
Dwi Okta N says
oh.. use the plugin. Iam just know it.
thx for info..
Craig says
I figured it out. My Search Result page wasn’t published yet.
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..
Ankit Yadav says
Works great.
Koala says
Thank you very helpful!![:)](https://www.wpbeginner.com/fr/wp-content/plugins/classic-smilies/img/icon_smile.gif)
Stacey says
Can the Google Search be used on Internal company websites?
If so how is this accomplished?
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??
Waleed Younas says
Really Helpful topic as always.
I am using a Plugin in my Site. How can I exclude ads from Search Results
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.
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?
WPBeginner Support says
It can be added but will not be able to show any results.
Administrateur
Claire Brotherton says
That’s what I thought. Thanks for your reply!![:)](https://www.wpbeginner.com/fr/wp-content/plugins/classic-smilies/img/icon_smile.gif)
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.
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.
Administrateur
saajan bedi says
Manually Adding Google Search doesn’t work (I’m using colormag theme), U need to Update the article
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.
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
Bruno Bezerra says
Beautiful tool! Having a search field is more than necessary.
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!
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.
Angelo says
Hi!
Do we have to choose among among the 5 font options available or we can import a font we like better?
wiziwiz says
how to set it so the results when clicked open in the content area?
wiziwiz says
otherwise thanks and awesome post
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.
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?
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
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
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
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
WPBeginner Support says
You can use both if you want. This will be a bit confusing for users though.
Administrateur
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.
Caroline says
The search results opens up in a new window, how can I open them in my search.php?
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.
boooka says
my search terms cannot be seen. what happened
Day Milovich says
i prefer to change wordpress search completely with google custom search engine to get better traffic from google.
Rahul Yadav says
Hi, I would like to know how to use google custom search in menus like you use……..
Vipul Behl says
Thanks for the tutorial i was able to create a search for my blog.
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.![:(](https://www.wpbeginner.com/fr/wp-content/plugins/classic-smilies/img/icon_sad.gif)
tony greene says
This doesn’t work for Genesis sites with child themes.
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?
Rajnish says
Really helpful post. I integrated search box for my Website successfully. Thanks WPBeginner![:)](https://www.wpbeginner.com/fr/wp-content/plugins/classic-smilies/img/icon_smile.gif)
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?
WPBeginner Support says
Chris, try regenerating code by creating a new custom search engine.
Administrateur
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.
WPBeginner Support says
Genesis is a theme framework, you should check out their documentation or use support forums.
Administrateur
Joy Baker says
Oops. Guess the form requires pre tags or something.
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.
WPBeginner Support says
yes replace the entire code with just the code for your Google CSE.
Administrateur
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.
Administrateur
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.
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 :
George Byers says
Thats great and all… but my search field is on the menu bar.
WPBeginner Support says
Look in the code if it is using the function <?php get_search_form(); ?> then this method should work for you.
Administrateur
John says
Thanks so much! You always have the best tutorials.
John
Huzaima Khan says
Really helpful post. I integrated search box for my blog successfully. Thanks WPBeginner![:)](https://www.wpbeginner.com/fr/wp-content/plugins/classic-smilies/img/icon_smile.gif)
amrilio says
Can you tell me, how to make share & comment button like your blog? please
WPBeginner Support says
We use a customized version of Floating Social Bar plugin.
Administrateur