So now that you've implemented Google Custom Search into your site, you may be wondering how you can sort the results. By default, Google does not sort the results at all. You may wish to sort by date to have your most recent posts appear at the top.
Here's how you can do that!
- Log in to Google Custom Search.
- Click on the Control Panel link next to your search engine.
- Click the "Advanced" link on the left hand side, then in the "Context" section, click "Download in XML format".
- Open the downloaded file in a text editor.
- Find the <BackgroundLabels> section of the file. Right before the </BackgroundLabels> line, add the following:
<Label name="recent4" mode="BOOST" />
- Save the file and go back to the Google Custom Search control panel.
- Under the "Context" section, click "Choose File", navigate to the file you've just edited, and click "Upload".
That's all there is to it! Your posts should now be sorted by date, with the most recent posts on the top of the results page.
Timo says
Hi Mitchell,
This seems to solve a problem that I have. But I cannot get it to work. I keep on getting an error about the XML file when I upload it to the CSE. Which editor do you use to edit the file?
Thanks for your help!
Timo
Mitchell Wischmann says
Hi Timo,
I use TextEdit on the Mac to edit the XML file. You should also be able to use Notepad on Windows. Just make sure it's being saved as an XML file.