Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Last active January 15, 2016 03:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchristopher/9486b9a6145bdaea16eb to your computer and use it in GitHub Desktop.
Save jchristopher/9486b9a6145bdaea16eb to your computer and use it in GitHub Desktop.
<?php
$swp_query = new SWP_Query(
array(
's' => 'coffee', // search query
'engine' => 'default', // engine to use
'post_type' => array(), // override enabled post types in engine config (SearchWP 2.7+)
'posts_per_page' => 10, // posts per page
'nopaging' => false, // disable paging?
'fields' => 'all', // set to 'ids' to return only post IDs (SearchWP 2.7+)
'page' => 1, // which page of results
'post__in' => array(), // limit potential results pool to array of IDs
'post__not_in' => array(), // explicity exclude IDs from search results
'tax_query' => array( // tax_query support
array(
'taxonomy' => 'people',
'field' => 'slug',
'terms' => 'bob',
),
),
'meta_query' => array( // meta_query support
array(
'key' => 'age',
'value' => array( 3, 4 ),
'compare' => 'IN',
),
),
'date_query' => array( // date_query support
array(
'year' => 2015,
'month' => 6,
'day' => 1,
),
),
)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment