Forums

How to hide certain meta key from admin-page/edit-post custom field? (2 posts)

  1. davidsutikno
    Member
    Posted 8 months ago #

    Hi,

    I'd like to hide my certain meta key from my edit-post custom field area.
    Let's say I have meta key with name "test1".
    I don't want that to be appeared on my edit-post/page. However, I still want to show other custom fields,like let's say "test2" "test3" "test4" etc.

    I've read something about remove_meta_box('postcustom','post','normal') but it hides all my custom fields.

    I also have read about renaming your meta key with "_test1". Yes, it's hidden, but the problem occurs since there's a plugin uses that meta key ("test1") as well. So renaming the meta key starts with underscore is not a good idea.

    Is there any code/function to hide certain custom fields?

    Thanks!

  2. davidsutikno
    Member
    Posted 8 months ago #

    I knew the answer!

    add_filter('is_protected_meta', 'my_is_protected_meta_filter', 10, 2);
    function my_is_protected_meta_filter($protected, $meta_key) {

    return $meta_key == 'test1' ? true : $protected;

    }

Reply

You must log in to post.

About this Topic