Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Avoid Accidental Publishing in WordPress

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Avoid Accidental Publishing in WordPress

Have you ever accidentally published a post on your blog? It can happen to any of us. Even the most experienced bloggers have accidentally hit the publish button. Recently one of our readers reached out to us asking for a good way to avoid accidental publishing in WordPress. In this article, we will show you how to avoid accidental publishing in WordPress.

Accidental publishing can become a major problem if you have automated the process of sharing posts on social media and newsletter. By the time you realize your mistake and unpublish the article, it is already shared on social networks, sent to email subscribers, and may even get indexed by search engines. If you want to avoid this, then follow this tutorial.

First thing you need to do is install and activate the Publisher Confirmation plugin. The plugin works out of the box, so there are no settings for you to configure.

Warning dialog box

Now when you hit the Publish button, this plugin will show a dialog box asking ‘Are you SURE you want to publish this post?’. Press OK if you are ready to publish the post, or press Cancel if you accidentally clicked the publish button.

Publish Confirmation plugin hasn’t been updated for more than two years. It works fine with the latest WordPress (3.8.1 at the time of writing this article) and probably don’t need updating. However we understand that some users might feel uncomfortable using an old plugin. Since the basic concept behind this plugin is extremely simple, you can implement it by simply pasting the following code in your theme’s functions.php file or in a site-specific plugin.

// This is the confirmation message that will appear.
$c_message = 'Are you SURE you want to publish this post?';
function confirm_publish(){

global $c_message;
echo '<script type="text/javascript"><!--
var publish = document.getElementById("publish");
if (publish !== null) publish.onclick = function(){
	return confirm("'.$c_message.'");
// --></script>';
add_action('admin_footer', 'confirm_publish');

That’s all, you are now protected from accidentally publishing posts on your WordPress blog.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. Saud Khan says:

    Hi, I’ve accidentally published a post and changed the status to draft. Should I noindex & nofollow it and what about permalink?

  2. Matthew Gates says:

    Thank you so much for this! I have only done this once… accidentally published an article that was not ready to go out. Luckily, the WordPress had scheduled it for some time in the far past, instead of “immediate”, so it never got published for anyone to see on the home page. However, my automatic social media feeds that are connected to my site did publish it to the feed. I only discovered this because I get an email when people share their articles on social media, but I had to spend about an hour tracking all the feeds it got published too and deleting the article off the feed. So this will definitely come in handy.

  3. Eric says:

    I’ve actually never had this problem myself and just recently discovered the Editorial Calendar which I think will help organize content for the future so I can plan things out, too.

    I like this tip though. You never know, just in case, it’s good to have it there.

  4. Matt says:

    I often just create a scheduled date a long time in the future, then remove it when I want to publish

  5. Jaymes says:

    Thanks for the article.

    If I do add the code to functions.php, won’t that be overwritten when a new version of WordPress is released?

    • WPBeginner Support says:

      No, but it will get overwritten when a new version of your theme is released and you update your theme. This is why we recommend our users to paste snippets in a site specific plugin.

  6. Artem Russakovskii says:

    Unfortunately, that doesn’t fix the issue for those of us using xmlrpc tools, like Windows Live Writer. I really wish there was a way to build UIs using xmlrpc responses.

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.