• Hi!

    I would like to get posts by keyword using query_posts.
    So, how can I query posts, that contain “big dog” as content?

    Thanks.

Viewing 1 replies (of 1 total)
  • Use a filter to add a WHERE condition:

    function mam_posts_where ($where) {
       global $mam_global_where;
       if ($mam_global_where) $where .= " $mam_global_where";
       return $where;
    }
    add_filter('posts_where','mam_posts_where');
    $mam_global_where = " AND $wpdb->posts.post_content LIKE '%big dog%'";
    query_posts(your args here);
    $mam_global_where = '';  // Turn the filter off!
Viewing 1 replies (of 1 total)

The topic ‘Query posts by keyword’ is closed to new replies.