Sorting Google Custom Search Results by Date

Google Custom Search Results

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!

  1. Log in to Google Custom Search.
  2. Click on the Control Panel link next to your search engine.
  3. Click the "Advanced" link on the left hand side, then in the "Context" section, click "Download in XML format".
  4. Open the downloaded file in a text editor.
  5. Find the <BackgroundLabels> section of the file. Right before the </BackgroundLabels> line, add the following:

    <Label name="recent4" mode="BOOST" />

  6. Save the file and go back to the Google Custom Search control panel.
  7. 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.


  1. 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!

Leave a Reply

Your email address will not be published. Required fields are marked *