On a WordPress site, in a product template, I have a section that shows a custom field value. On the site, the container is hidden by default. A visitor can click a button that slides open the container. The button is just in the template, static.
I am using this to show the value of my custom field:
if ( function_exists('get_custom_field_value') ){
get_custom_field_value('fieldname', true);
}
So what I’m trying to do is make it so the button only shows up if there is actually a value in the custom field.
I’m a total PHP newb. Any advice?
You can use get_post_meta() to check if custom field is empty or not: