Leave a Reply

3 comments

  1. DeluxeBlogTips.com 1) has an article on how to do combined searches in both posts and meta data. Basically, it involves two queries via the $wpdb object; one to search the meta table to get a list of post_ids and the other is a query of posts to get post_ids. You then merge the arrays and use that to do a query with a WP_Query using the posts__in argument.

    Using tags may be a bit tricky because 1. tags are meant to group posts together and 2. tags and taxonomies involve 3 different tables.

    1) The linked article is not completely right. It should be $keyword = "%".like_escape( $keyword )."%";.

  2. If you are truly opposed to a plugin, and know some SQL, you can do this with the $wpdb global variable.

    For example, to query all posts that contain “sample_text” in the title, you would do something like:

    global $wpdb;    
    $post = $wpdb->get_results("SELECT * FROM $wpdb->wp_posts WHERE post_title LIKE '%sample_text%' ");
    

    Then you would do similar things for each of the other tables.