nurpax / saastafi

Automatically exported from code.google.com/p/saastafi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

search to search by author as well

GoogleCodeExporter opened this issue · comments

Would be great to search an author's posts as well as just searching for a 
string in post body.

Something like

search "user:jasin SW" to search for SW posts by jasin.  

Or maybe just mentioning an author's login/screen name would search for his 
posts.

Implementation shouldn't be that difficult but I guess we'd need to touch 
innards of WP.

Original issue reported on code.google.com by jjhel...@gmail.com on 21 Jul 2007 at 1:45

I think searching "jasin SW" is a lot easier for everyone, not just the 
non-tech oriented people than "user:jasin 
SW". But yeah, to implement this we should hack WP.

But hey, would this do the trick for us: 
http://www.zirona.com/software/wordpress-advanced-search

Original comment by mikko.ur...@gmail.com on 28 Jul 2007 at 10:39

Right you are.  I'll take a look at the advanced search.

Original comment by jjhel...@gmail.com on 28 Jul 2007 at 11:08

I took a look at the advanced search plugin, seems to have enough features for 
us.

I have one issue with it though..  It doesn't say which versions of WP it's 
compatible with.  For example, some 
of the "sample sites" they linked to were not using AS anymore, due to 
incompatibilities with newer versions 
of WordPress:

8< --  http://www.bballcity.com/search/
Advanced Search

Unfortunately the advanced search page has been taken down due to 
incompatibilities with the newest version 
of wordpress. Feel free to use the regular search as it has been optimized to 
search by relevance instead of 
date.
8<

It would anyway be better to find a plugin for this rather than go and modify 
WP.

Original comment by jjhel...@gmail.com on 28 Jul 2007 at 11:16

Seems like WP already has some support for this.  For example, this

http://www.saasta.fi/saasta/?author=2

views only Sampo's posts.

Original comment by jjhel...@gmail.com on 28 Jul 2007 at 11:21

Yeah I think you've always been able to view posts per author, but I don't 
think it uses the search at all - viewing 
all posts by a specific author is a somewhat trivial SQL query :)

Anyhoo I'll keep on looking for better plugins.

Original comment by mikko.ur...@gmail.com on 29 Jul 2007 at 10:43

Yeah but I guess merging the text search with author search into a single SQL 
query shouldn't be that hard 
either?

But anyway, might still be better to find a plugin for this.

Would be great if it worked for both the screen name and the login name.

Original comment by jjhel...@gmail.com on 29 Jul 2007 at 10:53

Ok, I found a plugin called Search everything: 
http://wordpress.org/extend/plugins/search-everything/

But I'm unsure if it actually searches by author.. However, apparently you can 
do stuff like this:

### Function: Add Author Custom Fields
add_action('publish_post', 'add_author_fields');
function add_author_fields($post_ID) {
global $wpdb;
$user_id = $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = 
$post_ID");
$first_name = $wpdb->get_var("SELECT meta_value FROM $wpdb->usermeta WHERE 
meta_key = 'first_name' 
AND user_id = $user_id");
$last_name = $wpdb->get_var("SELECT meta_value FROM $wpdb->usermeta WHERE 
meta_key = 'last_name' 
AND user_id = $user_id");
$user_name = $wpdb->get_var("SELECT user_login FROM $wpdb->users WHERE ID = 
$user_id");
add_post_meta($post_ID, 'author_realname', $first_name.' '.$last_name, true);
add_post_meta($post_ID, 'author_username', $user_name, true);
}

Which, I think, adds user name etc as metadata which in turn is searchable by 
Wordpress.. I think :-) However 
according to this page 
(http://wordpress.org/support/topic/121766?replies=2#post-577154) it doesn't 
apparently do the trick.

Hangover is making this very, very difficult :-)

Original comment by mikko.ur...@gmail.com on 29 Jul 2007 at 11:10

Sounds very silly that they've gone through all this trouble and still NOT 
implement author search.  Perhaps we 
could just extend WP's own search?

BTW: I'm planning on fixing that silly thumbnail problem today.

Original comment by jjhel...@gmail.com on 29 Jul 2007 at 1:24

Assigning 2008-Q1 milestone.  This is clearly a needed feature.

Potential way to fix this: WP 2.3 upgrade?

Original comment by jjhel...@gmail.com on 29 Jan 2008 at 7:41

  • Added labels: Milestone-2008-Q1, Priority-High
  • Removed labels: Priority-Medium
Umm ok so the default search in WP 2.3 doesn't seem to do this, but I'm quite 
sure we can hack it into our 
already hacked search-tags thingy.

Original comment by mikko.ur...@gmail.com on 2 Feb 2008 at 2:45

Ok r108 has some kind of a fix implemented. It's by no means a perfect 
solution, but at least if you type the 
author name in the search box, you get a lot more hits :)

Janne, give it a spin will ya. If you want to compare to the old one, use 
either saasta.fi or comment the two lines 
that have "/* another change to search by author as well */" above them.

Original comment by mikko.ur...@gmail.com on 2 Feb 2008 at 9:06

I'm ok with Mikko's current implementation.  It's good enough, although doesn't
necessarily work with all combinations of user+title, user+tags+title etc.

For more searching, users are encouraged to use Google search, e.g., "jasin 
notorious
site:saasta.fi".

Original comment by jjhel...@gmail.com on 2 Feb 2008 at 11:35

  • Changed state: Fixed