Quantcast
Viewing all articles
Browse latest Browse all 8245

ndjworldnews on "Sql command needed"

Hi;
Tried posting this message in Wp-Advanced category but doesn't let me for some reason.

Question: what is the SQL command I need to use to retrieve the last 4 posts from the database?

I am using:

$posts = "SELECT * from $wpdb->posts WHERE post_type='post' ORDER BY post_date DESC LIMIT 4";

That works, except if I don't post anything for one day, that command doesn't pick up anything. How can I do this so that I always have the last four posts, regardless of when I published them?

Thanks for any suggestions.

Lode


Viewing all articles
Browse latest Browse all 8245

Trending Articles