Skip to content

Instantly share code, notes, and snippets.

@searchwpgists
Last active April 12, 2022 15:09
Show Gist options
  • Save searchwpgists/1d8294f9b268c6b6ebd0a814e46d6030 to your computer and use it in GitHub Desktop.
Save searchwpgists/1d8294f9b268c6b6ebd0a814e46d6030 to your computer and use it in GitHub Desktop.
<?php
// @link https://searchwp.com/documentation/classes/searchwp-statistics/
$statistics = \SearchWP\Statistics::get_popular_searches( [
// 7 days old or newer.
'days' => 7,
// The Engine used for searches.
'engine' => 'default',
// The search queries to ignore i.e. spam, junk.
'exclude' => [ 'spam search query', 'lorem ipsum' ],
// How many search queries to return.
'limit' => 5,
// With at least one result.
'min_hits' => 1,
// With at most 100 results.
'max_hits' => 100,
// Which site(s) to consider.
'site' => [ get_current_blog_id() ],
] );
// Display the stats in a <table>.
\SearchWP\Statistics::display( $statistics );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment