<?php
/**
* Hide Content Editors on Specific Pages
*
* This function hides the content editor on specific pages in the WordPress admin panel.
* It checks the current page and removes the editor for pages with specific titles.
*
* Gist Keywords: wordpress, editor, acf, content
* Author: Knol Aust
* Version: 1.0.0
*/
add_action('admin_head', 'knolaust_hide_editor');
function knolaust_hide_editor() {
global $pagenow;
// Check if we are on the post edit page or the page post type
if (($pagenow == 'post.php') || (get_post_type() == 'post')) {
// Get the post ID from the query parameters
$post_id = isset($_GET['post']) ? $_GET['post'] : (isset($_POST['post_ID']) ? $_POST['post_ID'] : null);
// Check if post ID is set
if (!isset($post_id)) {
return;
}
// Get the title of the post
$post_title = get_the_title($post_id);
// Define specific titles for pages where you want to hide the editor
$pages_to_hide_editor = array(
'About', // Add more titles if needed
);
// Check if the current page's title is in the list of titles to hide the editor
if (in_array($post_title, $pages_to_hide_editor)) {
remove_post_type_support('page', 'editor');
}
}
}
?>