GavernWP WordPress theme framework Quick Tip #7 – Unwanted Custom Post Fields

There is a problem that is common to certain WordPress plugins: some of them don’t properly store their post data. The plugin data specific to each post is stored in the Custom Post Fields, but without an underscore (“_”) at the beginning of the field name.

Meet GavernWP v.1.7 released! Without the underscore, the post data is determined to be public custom post fields. This is related to the fact that WordPress offers in their API the function is_protected_meta() which is used to check whether post metadata is a public Custom Post Field or not.

This function is very simple – it just checks if the metadata field contains the underscore at the beginning of its name. We have used this function in our Custom Fields mechanism to avoid displaying unnecessary post data.

Unfortunately, when a plugin doesn’t make use of this feature, all the plugin data associated with a specific post is displayed and this can cause users to wonder why they are seeing strange data at the end of the post.

If you’re using a plugin which is incorrectly storing data, you have three solutions:

  • Change the plugin ;)
  • Disable Custom Fields entirely in the Theme “Advanced” settings
  • Specify a list of the hidden Custom Post Fields as it was described in this post.

Incidentally, GavernWP framework also hides two other types of the custom fields starting with:

  • gavern-
  • gavern_
GavernWP WordPress theme framework Quick Tip #7 – Unwanted Custom Post Fields 5.005 (100.00%) 1 vote
This article was first published March 13th, 2013