WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i need to filter count based on a date and post_status = 'publish', how to write a query to filter, as far as now i have filtered based on date, what is the query need to filter based published post.

$table1 = $wpdb->prefix.'posts'; $sql = 'SELECT COUNT(ID) AS count FROM '.$users_table1.' WHERE DATE(post_date) < "'.date('Y-m-d',time()).'"'; $result = $wpdb->get_var($sql);

iam stuck with this, do anyone know this?

share|improve this question
up vote 0 down vote accepted

You can add this to the WHERE clause, just after your filter by post_date:

AND post_status = "publish"
share|improve this answer
    
thankyou it worked perfectly – Ezhil Aug 6 '11 at 9:18

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.