WordPress.org

Forums

Hiding custom post meta (7 posts)

  1. Steve
    Member
    Posted 3 years ago #

    I've got three custom post meta items that I'd rather not let the end user play with.

    All three of them are prefixed with an underscore and I'm creating them like this:

    update_post_meta($post->ID, '_wordbooker_extract', $excerpt);

    But they appear in the Custom Fields area on the Edit/Add Post/Page screens.

    Any idea what I'm doing wrong?

  2. NateJacobs
    Member
    Posted 3 years ago #

    Wrap your code that displays them on the page in an if ( ( current_user_can( $capability ) )

    If you want administrators to only see them the $capability could equal manage_options.

  3. Steve
    Member
    Posted 3 years ago #

    What I mean is that in the Custom meta block of the edit / add post they are appearing. According to the docs if I prefix the names with _ then they should be hidden but they are not.

  4. NateJacobs
    Member
    Posted 3 years ago #

    Take a look at the function remove_meta_box()

    http://codex.wordpress.org/Function_Reference/remove_meta_box

  5. Steve
    Member
    Posted 3 years ago #

    I DONT want to remove the meta box. I want to stop my meta data from appearing in the custom meta box which acording to the documenation I do by prefixing with _

    http://codex.wordpress.org/Function_Reference/add_post_meta

    "If you are a plugin/theme developer and you are planning to use custom fields to store parameters related to your plugin or template, it is interesting to note that WordPress won't show keys starting with an "_" (underscore) in the custom fields list at the page/post editing page or when using the template the_meta() function. Depending on how you plan to use the meta data, you may want to hide the values from the the admin UI by prefixing their names with an underscore. "

    Which is obviously broken

  6. esmi
    Forum Moderator
    Posted 3 years ago #

    Which is obviously broken

    Hmm... it's working just fine in the eShop plugin.

  7. Steve
    Member
    Posted 3 years ago #

    so I wonder why _fieldname isn't working for me....

Topic Closed

This topic has been closed to new replies.

About this Topic