something along these lines
function SearchFilter($query) {
if ($query->is_search) {
// Insert the specific post type you want to search
$query->set('post_type', 'page');
}
return $query;
}
// This filter will jump into the loop and arrange our results before they're returned
add_filter('pre_get_posts','SearchFilter');
in your functions.php
perhaps
Is there a more simple way to do it?
Looks like this plugin can be configured to search only what you want:
http://ww.wp.xz.cn/plugins/search-everything/
it says you can exclude posts but I haven’t used it.
try googling “wordpress search plugin exclude posts” or “wordpress search plugin only pages” or whatever
e.g. http://ww.wp.xz.cn/plugins/simply-exclude/
Thank you. What I don’t get is how to actually get a search function. I have my search.php but don’t get how to actually have a search engine on my website.
you mean you want to add the search box?
the code for that is <?php get_search_form(); ?> afaik
you might want to look in the widgets section, there may be a search box in there you can just drag into the sidebar.
Here’s my website… hidefspaces.com
it only has a little search box at the top right that isn’t really customizable. I’d like to have maybe just a page itself that is used to search properties like the one on trulia.com