Last active
November 27, 2024 21:10
-
-
Save snrjosh/46831bdddb6bf09f6cfaa9b9e9ec02e7 to your computer and use it in GitHub Desktop.
Hide ACF field on the Admin screen
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 | |
/** | |
* Prevent a field from being rendered | |
* Filter : https://www.advancedcustomfields.com/resources/acf-prepare_field/ | |
* | |
*/ | |
function hide_acf_field_on_admin( $field ) { | |
// Don't show this field if it contains a value. | |
if ( $field['value'] ) { | |
return false; | |
} | |
return $field; | |
} | |
//Specify field name. | |
add_filter( 'acf/prepare_field/name=field_name', 'hide_acf_field_on_admin' ); | |
/** | |
* Via CSS | |
* ACF provides a `acf-hidden` class in acf-global.css, | |
* which adds a `display: none` to the field in the admin. | |
* Simply add `acf-hidden` as a class on the field "Wrapper Attributes" | |
* to hide it on the admin interface. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment