0

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?

1

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

AND post_status = "publish"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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