WP_Query with “post_title LIKE ‘something%’” and category

I need to do a WP_Query with a LIKE on the post_title and category

This query_post is not working

query_posts(
     array(
        'post_type' => 'add_buying',
        'like' => $keywords,
        'posts_per_page' => 5,
        'taxonomy' => 'add_country',
        'term' => 'drawing'
 ));

Related posts

Leave a Reply

3 comments

  1. Check this url and change the like parameter.

    query_posts( array(
    'post_type' => 'add_buying',
    's' => $keywords,
    'posts_per_page' => 5,
    'taxonomy' => 'add_country',
    'term' => 'drawing' 
    ));
    
  2. Change your second parameter to ‘s’ and I think it’s going to work:

    $args = array(      
        'post_type'   => 'post',
        's'           => $search_term,
        'post_status' => 'publish'    
    );
    $wp_query = new WP_Query($args);
    

    And good luck

  3. title (string) – use post title (available with Version 4.4).

    $args = array(      
        'post_type'   => 'post',
        'title'       => $title,
        'post_status' => 'publish'
    ); 
    $wp_query = new WP_Query($args);