Skip to content

Instantly share code, notes, and snippets.

@utkrishta
Last active June 15, 2020 23:32
Show Gist options
  • Save utkrishta/0b7896d24caae97ef3805ac6466949c5 to your computer and use it in GitHub Desktop.
Save utkrishta/0b7896d24caae97ef3805ac6466949c5 to your computer and use it in GitHub Desktop.
Hide Given ACF fields on custom post type
<?php
//Hide given ACF fields on "my_cpt" post_type
function my_custom_function() {
global $current_screen;
if ( 'my_cpt' == $current_screen->post_type ) {
?>
<script>
(function () {
var x = document.querySelectorAll("a[data-key='field_5ea76a5ac9b48']");
//change data-key as required
var i;
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
})();
</script>
<?php
} else {
//echo 'not my_cpt';
}
}
add_action( 'admin_head', 'my_custom_function' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment