Limit SearchWP results to Category that has 'foobar' slug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, is there anyway to limit search results to 100 posts | 10 per page?