0

Does anyone know how I can get a list of posts based on their recent activity? Activity such as a new comment, an edit, a new post, et cetera.

Some Q&A wordpress themes seem to be using this but I have no clue on how to generate such a query myself...

Please, it's very important.

1 Answer 1

1

This needs to be 2 queries, one to get the posts most recently commented like:

$q = "SELECT wp_comments.comment_post_id, wp_posts.* FROM wp_comments LEFT JOIN wp_posts ON wp_comments.comment_post_id = wp_posts.ID ORDER by wp_comments.comment_date DESC";

And one to get the most 10 recent posts by add or edit:

$q = "SELECT * FROM wp_posts WHERE post_type='post' OR post_type='revision' ORDER BY post_date DESC";

But when you retrieve the posts from the latter you will need to check if it is a revision and if so get the parent post, and also depending on the reason for this check the status of the post or the parent post to make sure it is published (status of revisions will be inherit)

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.