gsa700 Posted March 4, 2008 Share Posted March 4, 2008 Hi all, I am new here and hoping I am posting this in the right place. I am using wordpress as a front end to mySQL to add news items to a database and then using PHP to grab them from the db and include them in a php page. The problem I am having is that I am very basic in my php and adding the db into the equation is more than I can grasp here. So what I need is this: the following code works very well with one exception, it includes ALL posts even if they are no yet published. There is a "post_status" available which is either: "publish" or "draft". I basically want to have my code check to make sure that "post_status" = "publish" before it adds it to the page. Here is my existing code: ( for some reason I couldn't include the code itself so here is a picture of the code ) Any help here would be appreciated. Quote Link to comment Share on other sites More sharing options...
Stooney Posted March 4, 2008 Share Posted March 4, 2008 change this line: $query.=" FROM wp_posts ORDER BY id DESC LIMIT 3"; to $query.=" FROM wp_posts WHERE post_status='publish' ORDER BY id DESC LIMIT 3"; Quote Link to comment Share on other sites More sharing options...
priti Posted March 4, 2008 Share Posted March 4, 2008 you are missing with WHERE condition in your query Quote Link to comment Share on other sites More sharing options...
gsa700 Posted March 4, 2008 Author Share Posted March 4, 2008 change this line: $query.=" FROM wp_posts ORDER BY id DESC LIMIT 3"; to $query.=" FROM wp_posts WHERE post_status='publish' ORDER BY id DESC LIMIT 3"; I knew it was something simple. ;-) Thank you very much! I did not expect such a fast reply. You guys rock. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.