Articles

Removing Salient Postboxes When Using SCF or ACF

27
0

Sometimes I build weird things. 😆

This one started as a horse show document repository for The Michigan Quarter Horse Association. The page uses a bunch of Custom Fields to dynamically output PDF document repositories.

Because the Salient theme’s post editor already contains the output code, there was no reason for the client to have access to the normal WordPress page editor, categories, tags, excerpts, or a bunch of other meta boxes.

Instead of hiding everything with a pile of CSS/theme hacks, I used a simple WordPress function to programmatically remove the unnecessary boxes and editor for this specific page. The client gets exactly what they need: the Custom Fields they actually use.

A little admin cleanup can go a long way toward making WordPress easier for clients to manage. Add this to your functions.php in the theme folder.

function wd2345_hide_meta_boxes() { // Change the function name here for multiple pages $post_id = isset($_GET['post']) ? $_GET['post'] : (isset($_POST['post_ID']) ? $_POST['post_ID'] : ''); if ($post_id == 2345) { // Change the Post ID here remove_meta_box('postexcerpt', 'post', 'normal'); remove_meta_box('categorydiv', 'post', 'normal'); remove_meta_box('wpb_wpbakery', 'post', 'normal'); remove_meta_box('tagsdiv-post_tag', 'post', 'normal'); remove_meta_box('nectar-metabox-page-header', 'post', 'normal'); remove_meta_box('authordiv', 'post', 'normal'); // Remove the editor and leave only the Custom Fields. remove_post_type_support('post', 'editor'); remove_post_type_support('page', 'editor'); } } add_action('add_meta_boxes', 'wd2345_hide_meta_boxes', 99); // Change the function name here for multiple pages

Sometimes the best WordPress admin interface is the one where the client never has to see all the stuff they don’t need.