Reputation: 89
I have a Mysql query set outside the wordpress loop, like the one below, which doesn't work. I would like to know how can I filter the sql results based on the author that created the post.
global $post;
$post_author = $post->post_author;
$sQuery = "SELECT DATE_FORMAT((post_date), '%M/%Y') 'Month',
FROM wp_posts p WHERE p.post_author = '$post_author'
Any assistance is appreciate it.
Thank you,
Upvotes: 0
Views: 319
Reputation: 1269953
You have an extra comma after 'Month'
. Try this:
$post_author = $post->post_author;
$sQuery = "SELECT DATE_FORMAT((post_date), '%M/%Y') 'Month' FROM wp_9691posts p WHERE p.post_author = '$post_author'";
I also added the final "
to enclose the query string.
Upvotes: 1