jave.web
jave.web

Reputation: 15052

How to allow empty Custom Fields?

I found Custom Fields in WordPress as really good helper, I don't have any problems with checking whether the Custom Field is or is not empty so I can show it or hide it. But there's a big BUT:

Problem: WordPress 3.5.2. doesn't allow empty Custom Fields (not in default behaviour), and user is not a database of the meta names he can use - so I want to preset the names for the user - some names will have empty value... so...

The Question is: how to allow empty Custom Fields? Or how to disable the WP empty check?

EDIT: The english error message is "Please provide a custom field value."

EDIT2: I am looking for a solution that allows empty Custom Field not using some placeholder instead - just to be clear.

So if you don't mind having some placeholder your solution would be:
1) add a word like "nothing" as value
2) then check:

if( trim($meta)=="nothing" ) { /* code for "empty" value */ }
   else { /* code for "non-empty" value */ }

Upvotes: 1

Views: 581

Answers (1)

Praveen Shekhawat
Praveen Shekhawat

Reputation: 360

you can also use this plugin for Advance Custom Field.

Advance Custom Field

Please download it and check.

Upvotes: 1

Related Questions