Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to get posts according to the following logic:

"If post status = publish or pending then get all records which have a meta value of less than todays date. If the post is in trash, get it regardless of meta query"

So I have the following args but these bring in only the trash posts that have meta value of less than todays date and I want to get all trash posts.

$args = array(
    'posts_per_page' => -1,
    'post_type' => 'jobs',
    'post_status' => 'pending, publish, trash',
    'author' => $current_user->ID,
    'meta_key' => 'JOBS_ad_end',
    'meta_query' => array(
        array(
            'key' => 'JOBS_ad_end',
            'value' => date("Y-m-d"),
            'compare' => '<=',
            'type' => 'NUMERIC,'
        ) 
    )
);
$posts = get_posts($args);

I'm guessing this probably isn't even possible and will need a custom query, but thought I'd check if anyone knows a way to do it.

share|improve this question
1  
No, WP_Query is not capable of logic that complex, but this answer should get you started: wordpress.stackexchange.com/a/115236/21376 –  s_ha_dum Nov 13 '13 at 14:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.