Google custom search results per page

Google custom search results per page

Rate this article

Share this article

Read Remove URLs in Google custom search for more information.

Introduction

Google Custom Search (GCS) has a limit of 100 search results for each query. These results are presented ten per page, for a total of ten pages. If you do not find your answer in these results, refine your query and search again.

If a search query produces fewer than ten pages of results, GCS search returns will still show navigation links for ten pages. Links to all pages beyond the last actual page will redirect to the final results page; for example, if a search produces only eight pages of results, then links to pages 9 and 10 will redirect to page 8.

Google custom search results per page

 

Make a fully customizable search without any coding

Changing the Code

The results per page for Google custom search can be changed by using the following code.

<?php
$q = $_GET['q'];
$num = $_GET['num'];
if(empty($num)){
    $num = 10;
}
?>

<div id="gsc">
    <script>
      (function() {
        var cx = '(My API Key)';
        var gcse = document.createElement('script');
        gcse.type = 'text/javascript';
        gcse.async = true;
        gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
        var s = document.getElementsByTagName('script')[0];
        s.parentNode.insertBefore(gcse, s);
      })();
   </script>
   <gcse:searchbox-only resultsUrl="?num=<?php echo $num; ?>" filtered_cse=1></gcse:searchbox-only>
</div>

<ul>
    <li><a href="?num=10&q=<?php echo $q; ?>">10</a></li>
    <li><a href="?num=20&q=<?php echo $q; ?>">20</a></li>
    <li><a href="?num=30&q=<?php echo $q; ?>">30</a></li>
</ul>

<div id="results">
    <gcse:searchresults-only webSearchResultSetSize="<?php echo $num; ?>"></gcse:searchresults-only>
</div>

Of course, Google has not made this process easy. Though custom search does come with some customizability, it does not provide it at the level that most users need today. For this reason, it is always advisable to go for an alternative.

Build a custom search engine at 9 USD per month

Are you showing the right products, to the right shoppers, at the right time? Contact us to know more.
You may also like