Last active
October 18, 2016 19:31
-
-
Save stephanieleary/2515588 to your computer and use it in GitHub Desktop.
Warn users not to edit the post container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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