|  About Me  |  Blogs  |  Photos  |  Publications  |  Resume  | 

WordPress 1.5 hack to search custom field values

I previously installed the RustAside & RustLinkOff plugins to add sidenotes and links to my blog enty. Got it to work beautifully except that the content is not searchable. I found this Search Meta Hack that makes search queries look at custom field values in addition to post content. The patch didn’t apply cleanly so here’s my actual diff after the manual patch:

363a364,366
>                               for ($i = 0; $i < count($s_array); $i = $i + 1) {
>                                       $search .= ' OR ('. $wpdb->postmeta .'.post_id='. $wpdb->posts .'.id AND '. $wpdb->postmeta .'.meta_value LIKE \''. $n . $s_array[$i] . $n . '\')';
>                               }
550c553
<               $request = " SELECT $distinct * FROM $wpdb->posts $join WHERE 1=1".$where." ORDER BY " . $orderby . " $limits";
---
>               $request = " SELECT $distinct * FROM $wpdb->posts, $wpdb->postmeta $join WHERE 1=1".$where." ORDER BY " . $orderby . " $limits";

Leave a Reply

You must be logged in to post a comment.