I have a custom field called "warning", which I use for common content advisory notices. The default value for this custom field is "None" as I wanted to give people the option of filtering posts to include only those that have no content advisory notices. I would like to display the "warning" filed in my posts only when the value is NOT "None". Is this possible? Can someone explain how or point me to some examples?
<?php if(get_post_meta($post->ID, 'warning', true) != 'None') { ?>
<!--possible html tags here-->
<?php echo get_post_meta($post->ID, 'warning' ,true); ?>
<!--possible closing html elements here-->
<?php } ?>
Explaining alcymyth's code:
<?php if(get_post_meta($post->ID, 'warning', true) != 'None') { ?>
If the "warning" is NOT none, do stuff.
<?php echo get_post_meta($post->ID, 'warning' ,true); ?>
Show contents of the "warning".
If this topic is solved, please mark it as "Resolved" on your right sidebar.
Cheers.