Custom Fields error
-
I’m getting an error when I do not have any values for the ‘purchase’ custom field I have created.
Here is the error.
Warning: Invalid argument supplied for foreach() in /home/terminal/www/www/wp-content/themes/terminaldusk/pageDiscogNew.php on line 40I know this is b/c the purchase links are null but how do i stop this error from showing or perhaps show some different code when there are no ‘purchase’ custom fields.
<?php $purchaselinks = get_post_meta($post->ID, 'purchase', true); if($purchaselinks) : ?> <h3>Purchase</h3> <p>If you know a place to purchase this record that is not listed <a href="http://www.terminaldusk.com/contact">please let us know</a>.</p> <?php endif; ?> <?php $value = get_post_meta($post->ID, 'purchase', false); ?> <ul class="purchaseLinks"> <?php foreach($value as $value) { if($value == 'purchase-addictech') { echo '<li><a href="http://terminaldusk.addictech.com/">Addictech (Mp3)</a></li>'; } elseif($value == 'purchase-adnoiseam') { echo '<li><a href="http://www.adnoiseam.net/store/terminal-dusk_m40.html?osCsid=68c63d8a5c49d673d3f3a009e2a2a9b7">Ad Noiseam (DE)</a></li>'; } elseif($value == 'purchase-amazon') { echo '<li><a href="http://www.amazon.com/s/qid=1245201707/ref=sr_f3_all?ie=UTF8&rs=&keywords=terminal%20dusk&rh=i%3Adigital-music%2Ck%3Aterminal%20dusk%2Ci%3Adigital-music-album">Amazon.com (Mp3)</a></li>'; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Custom Fields error’ is closed to new replies.