Hello.
I'm wondering if there is a way to search all the wordpress site, Pages and Posts, or if the search features only handle posts? If so are there any workarounds to this?
Hello.
I'm wondering if there is a way to search all the wordpress site, Pages and Posts, or if the search features only handle posts? If so are there any workarounds to this?
May be put up a Google search box? It searches throughout the site.
It only handles posts as of now, though there is a Search Pages plugin/hack for this.
good ideas both. I'll look into them.
I tried to change the classes.php file (it's in your wp-includes folder) since this is the class that constructs the query that will get your posts esp the function &get_posts(). I don't really know if this is alright or there's a safer workaround, but right now it's working for me.
I use WP2 and in line 601 of classes.php (in function &get_posts()) I added these 2 lines:
} elseif ($this->is_search) {
$where .= ' AND (post_status = "publish" OR post_status = "static")';
So it goes like this (start from line 595):
if ( $this->is_attachment ) {
$where .= ' AND (post_status = "attachment")';
} elseif ($this->is_page) {
$where .= ' AND (post_status = "static")';
} elseif ($this->is_single) {
$where .= ' AND (post_status != "static")';
} elseif ($this->is_search) { //added line
$where .= ' AND (post_status = "publish" OR post_status = "static")'; //added line
} else {
$where .= ' AND (post_status = "publish"';
if (isset($user_ID) && ('' != intval($user_ID)))
$where .= " OR post_author = $user_ID AND post_status != 'draft' AND post_status != 'static')";
else
$where .= ')';
}
Critics??
NB: You also need to customized your search.php file so that after every page you won't see "Posted in <default_category> | <Comments>"
Critics??
Yep, having a plugin for that I think modifying the core files is NOT a good idea. Most users will forget about it and at the next upgrade they'll cry about borked sites.
Use or make a plugin :)
Yeah. I thought about it too. I've made several plugins myself but I haven't found a good way for this issue. This is just a pragmatist solution.
The problem that I have in mind is how am I going to alter the construction of posts from query results made by the function &get_posts() using a plugin. Or maybe a workaround on The Loop? Or maybe I'm just too dumb for this..
What's the plugin/hack that have succeded in doing this? I've looked around but maybe I missed it somewhere.
Thanks for the reply.
I am not a coder, so I don't have an answer for your questions. Here is the plugin I use in several installs for searching Pages:
http://randomfrequency.net/wordpress/search-pages/
Whoa.. I've seen the plugin. And I feel really stupid now. Why didn't I think of that before? Thanks.
This topic has been closed to new replies.