0

This error appears when I try to activate one option in widget. I broke it in multiple lines so it may be easier to review. I hope it should be very quick to fix code for someone who is familiar with SQL. I appreciate your time!

WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'post_status='publish' AND post_type in ('post') GROUP BY ID OR' at line 14]

SELECT ID as post_id,
SUM(x.facebook_shares+x.twitter_shares) as a, 
SUM(x.facebook_shares - x.facebook_shares_start +x.twitter_shares - x.twitter_shares_start) as d 
,post_title, 
post_content FROM wp_top_stories x inner join wp_posts on ID=id_post 
AND dt_day>'2017-09-19' WHERE ( (x.facebook_shares - x.facebook_shares_start +x.twitter_shares - x.twitter_shares_start) >0 ) 
post_status='publish' AND post_type in ('post') GROUP BY ID ORDER BY d DESC LIMIT 0,5 
2
  • is one of your plugins creating this SQL request ?
    – mmm
    Commented Oct 19, 2017 at 20:26
  • No, it is commercial plugin but it is fixed now.
    – Valeka
    Commented Oct 20, 2017 at 9:26

1 Answer 1

1

You need an AND before post_status='publish'

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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