Quantcast

Adding a confirmation for WordPress posts tagged with the default category.

The standard install of WordPress automatically adds new posts to the ‘Uncategorized’ category, and it’s up to you remove the tag. Peliom sez:

by default posts are tagged as “Uncategorized,” and no warning when I forget to tag. This is more annoying than it sounds.

I added a confirmation to our WordPress install that warns you when you are about to save or publish a post with the default category selected. If you want to do this too, make these two small edits to edit-form-advanced.php:
<form name="post" action="post.php" method="post" id="post"> becomes:
<form name="post" action="post.php" method="post" id="post" onsubmit="return confirmCategorySelected()">
and add this function to the file:

<script type="text/javascript">
function confirmCategorySelected() {
	if (document.getElementById('category-1').checked) {
		return confirm('The default category (Uncategorized) is still checked. Do you really want to continue with this post?');
	} else {
		return true;
	}
}
</script>

3 Responses to “Adding a confirmation for WordPress posts tagged with the default category.”

  1. may
    October 2nd, 2006 | 7:01 am

    yay! :-)

  2. June 30th, 2007 | 10:46 pm

    i really need a confirmation code for tagged please send me one asap

  3. June 30th, 2007 | 10:48 pm

    i really need my code so i can get on tagged pronto

Leave a reply