Skip to content

Instantly share code, notes, and snippets.

@stephanieleary
Last active October 18, 2016 19:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stephanieleary/2515588 to your computer and use it in GitHub Desktop.
Save stephanieleary/2515588 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_notices', 'scl_postspage_print_notices' );
function scl_postspage_print_notices() {
$screen = get_current_screen();
if ( $screen->parent_base != 'edit' || $screen->base != 'post' || $_REQUEST['action'] != 'edit' )
return;
$posts_page = get_option( 'page_for_posts' );
if ( !$posts_page )
return;
if ( $_REQUEST['post'] == $posts_page )
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