-
-
Save saas786/2516981 to your computer and use it in GitHub Desktop.
Warn users not to edit the post container
This file contains 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_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