WordPress is creating a lot of draft posts

A good place to start with an issue like this is using debug mode in WP. https://codex.wordpress.org/Debugging_in_WordPress If you know exactly which action triggers the creation of a draft post, then it is repeatable and you have a basis for a solution. Based on your question, “whenever I load the posts page” is what creates … Read more

WordPress – Update all existing posts at once

I’m not sure if it will work, but you could try running wp_update_post() on all posts concerned. It will trigger the save_post hook. According to the Codex: Unlike wp_insert_post(), it is only necessary to pass the ID of the post to be updated and the elements to be updated. You could try looping an array … Read more

Latest comment post should be the first post in the blog

WordPress post queries don’t natively support ordering by such specific comment information, only by comment count. Rest of comment-related things aren’t stored in posts table and not available for easy querying. While it’s probably possible to cook up SQL for this, I think it would be more practical to store date of comment in its … Read more

Automatically create a loop for post ID

“The Loop” is already a loop, so I don’t see the need for your second loop. In fact, the secondary while loop shouldn’t work because you keep resetting it to 1 for every post. You also have some PHP syntax issues like $echo (that’s a variable) instead of echo and the way you concatenate the … Read more