Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Limit SearchWP results to Category that has 'foobar' slug
<?php
// Limit SearchWP results to Category that has 'foobar' slug.
$search = new \SWP_Query( [
's' => 'coffee', // Search string.
'tax_query' => [ [
'taxonomy' => 'category',
'field' => 'slug',
'terms' => 'foobar',
] ],
] );
// Print all results.
print_r( $search->posts );
@phamquangbaoplus
Copy link

phamquangbaoplus commented Apr 29, 2021

Hello, is there anyway to limit search results to 100 posts | 10 per page?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment