post_type restriction on wp_query doesn't work?
-
I’m flummoxed. Although I thought I implemented a post type restriction correctly in WP_Query, I’m still getting returned posts that are NOT in my post_type.
Here’s the sitch:
I have a custom post type (“providers”) created through Custom Post Type UI version 0.8.2 .
I want to display *only* providers (not posts) that match a search term stored in $providername. Here’s my code. Note that I have Relevanssi enabled, which is why there’s some conditional code, but whether it’s activated or not, I’m still getting a search result that includes posts as well as providers. I want providers only, and not other post types, in this case the standard WP “post”. What am I missing?
if (!empty($providername)) { $args = array( 'post_type' => 'providers', 's' => $providername, 'posts_per_page' => -1 ); if (function_exists(relevanssi_do_query)) { $blog_query = new WP_Query($args); relevanssi_do_query($blog_query); } else { $blog_query = new WP_Query($args); } }
- The topic ‘post_type restriction on wp_query doesn't work?’ is closed to new replies.