Toppers
Toppers

Reputation: 549

Wordpress meta_query not working properly

I have added a meta query to get the details less than the compared id. It is working fine if the last id is 999 but it is not working if passing last id as 1000. I tried a lot but still no luck.

Meta Query

 $rd_args = array(
'post_type' => 'estate_property',
'post_status' => 'publish',
'no_found_rows' => 'true',
'posts_per_page' => '2',
'order' => 'DESC',  
'meta_query' => array(          
    array(
        'key' => 'ID',
        'value' => $_POST['last_id'],
        'compare' => '<'
    )
  )
);

I am not getting where I am wrong.

Thanks

Upvotes: 0

Views: 451

Answers (1)

Toppers
Toppers

Reputation: 549

Finally I got the answer, the issue was the datatype of ID in database. I have added the type in meta_query and it started to work. Thanks every one.

  'meta_query' => array(          
   array(
    'key' => 'ID',
    'value' => $_POST['last_id'],
    'compare' => '<',
    'type' => 'numeric'
   )
 )

Upvotes: 1

Related Questions