Searched quite a bit in Google and cannot find this. I'm aiming to limit a WP search to just Pages (excluding a few) and Posts from a specific category.
I've seen many examples of including or excluding categories (on the latter, far too many blogs have copied/pasted wrong code where they don't include the "-" operator), and examples of including custom posts or pages, but none that combine this.
I've tried using functions in functions.php that hook into pre_get_posts, as well as hidden inputs in the search form that have a name of "cat" and a value of the IDs, but nothing is working quite right to achieve what I'm after.
<form id="searchform" method="get" action="<?php bloginfo('home'); ?>">
<input type="text" name="s" id="s" size="15" value="<?php echo trim( get_search_query() ); ?>" />
<input type="image" class="left" id="sc_search_button" src="/images/search-icon.png">
<input type="hidden" value="12" name="cat" />
<input type="hidden" value="page" name="post_type" />
</form>
Above is what I'm using for the form, fwiw. Advise is much appreciated.