Is there a ‘compare’ option when using WP_Query apart from meta_query

Question

I understand the use of compare in the context of meta-query, but I’d like to know if it’s possible to do a compare on another column in the wp_posts table via WP_Query. I wrote this first, which works fine:

    $results = $wpdb->get_results( 
        $wpdb->prepare( 
            'SELECT id, post_title, post_name  
             FROM '.$wpdb->prefix.'posts
             WHERE post_type = %s  
             AND post_status = %s
             AND post_title REGEXP "%s"
             ORDER BY post_date ASC',
             'post',
             'publish',
             'Daily Task:'
        )  
    );  

but in trying to let WordPress do the work, I would like something like this:

    $results = new WP_Query( array (
        'post_type'   => 'post',
        'post_status' => 'publish',
        'orderby'     => 'post_date',
        'relation'    => 'AND',
        array ( 'compare'     => 'LIKE%',
                'post_title'  => 'Daily Task: '
              )
        )
    );

I’ve searched the Interwebs and the Codex and all I find are references to meta_query. Is that because compare, LIKE, or REGEXP doesn’t apply to WP_Query?

Thanks!

0
breadwild 1 month 0 Answers 11 views 0

Leave an answer