Joomla & WordPress Tutorials, Info, Discussion, Tips | GavickPro Blog

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.

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:

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

Share