Function only for admin area?
-
Hi, I wanted to run the following only in the admin area only.
// Hide ACF Content Box
function hide_post_box() {
global $post;
if ( 34 == $post->ID ) {
echo '';
} elseif ( 31 == $post->ID ) {
echo '';
}
add_action('admin_head', 'hide_post_box');How would I adjust this to do that, currently it fires on the front end as well and the logs are showing a PHP Warning: Attempt to read property “ID” on null.
Something like this?
if ( is_admin() ) {
function hide_post_box() {
global $post;
if ( 34 == $post->ID ) {
echo '';
} elseif ( 31 == $post->ID ) {
echo '';
}
}
add_action('admin_head', 'hide_post_box');
}
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Function only for admin area?’ is closed to new replies.