I have the following code:
<?php $buycheck = get_post_meta($post->ID, 'buy-link', true); ?>
<?php if ( $buycheck ) : ?>
<div class="section-title sidebar span5">
<h5>Get This Release</h5>
</div>
<?php else : ?>
<div class="section-title sidebar span5">
<h5>More Releases</h5>
</div>
<?php endif; ?>
Later in my code I want to be able to say that if buy-link does not exist – i.e. there is no data in that field – then do something, else do something different.
Not sure how to do this! Help appreciated!
(By the way, I posted this question to WordPress Stack Exchange first. It was voted closed there because it apparently concerns PHP boolean logic more than WordPress – https://wordpress.stackexchange.com/questions/60387/how-do-i-do-if-post-meta-does-not-exist#comment78412_60387)
this will render $buycheck, and if it is empty == is equal to ” nothing.