Skip to content

Instantly share code, notes, and snippets.

@saas786
Forked from stephanieleary/posts-page-warning.php
Created April 28, 2012 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saas786/2516981 to your computer and use it in GitHub Desktop.
Save saas786/2516981 to your computer and use it in GitHub Desktop.
Warn users not to edit the post container
<?php
// Add to functions.php or place in mu-plugins
// Admin Notice on Posts Page
add_action('admin_head-post.php', 'us2011_postspage_error_notice');
function us2011_postspage_error_notice() {
$postspage = get_option('page_for_posts');
if (!empty($postspage))
add_action('admin_notices', 'us2011_postspage_print_notices');
}
function us2011_postspage_print_notices() {
$postspage = get_option('page_for_posts');
// show this only if we're editing the posts page
if (!empty($postspage) && isset($_GET['action']) && $_GET['action'] == 'edit' && $_GET['post'] == $postspage)
echo '<div class="error"><p>This page is a container for the most recent posts. It should always be empty, and you should never edit this page. To add a news item, go to <a href="post-new.php">Posts -- Add New</a>.<p></div>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment