I learned this trick when someone asked about How to Hide Custom Fields Meta Key from Custom Fields panel. This trick useful when you want to hide certain Custom Fields Meta Key and Value from client or authors
Add following code to functions.php
add_filter('is_protected_meta', 'my_is_protected_meta_filter1', 10, 2); function my_is_protected_meta_filter1($protected, $meta_key) { return $meta_key == 'mymetakey_no1' ? true : $protected; }
This code to hide a Custom Field Meta Key, just change mymetakey_no1 to meta key name that you wanted to hide. What if you want to hide two Meta Key?, add following to functions.php underneath above code
[/php]
add_filter(‘is_protected_meta’, ‘my_is_protected_meta_filter2’, 10, 2);
function my_is_protected_meta_filter2($protected, $meta_key) {
return $meta_key == ‘mymetakey_no2’ ? true : $protected;
}
[/php]
Leave a Reply