wordpress - Custom Fields/Meta Boxes - Only Display If Value is Present -
I am using WordPress add-ons to create custom fields for custom post types. I < p> Currently, I am using this code:
& lt; php $ However, I have a value for a specific custom field, only then I need a way to display content. url = get_post_meta ($ post-> ID, 'snippet-context-url' is true); If ($ url) {resonant "<"; Lt; P & gt; & Lt; a href = '$ url' & gt; Reference URL & lt; / A & gt; & Lt; / P & gt; However, this field displays if the field exists (which is always in this situation). I need a code which is only a specific field.
The check given on this example
< code> & lt ;? php $ key_1_value = get_post_meta (get_the_id (), 'key_1', true); // Check if there is a value in custom field (! ($ key_1_value empty!) {echo $ key_1_value;} ? & gt;
Comments
Post a Comment