get_post_meta default image
-
Hello WP fans,
I’ve been struggling to set up a default image on posts using a custom field and was wondering if anyone could assist.
Here is the code:
<?php $Image = get_post_meta($post->ID,'Image', true); $Image = ( !empty( $Image ) ) ? $Image : 'https://www.mysite.com/wp-content/uploads/2010/09/placeholderimage-14.jpg'; print '<img class="pageimg" src="' . $Image . '" width="183" height="196" alt="" />'; ?>
I believe I’ve missed something, but my PHP skills are seriously lacking… The regular image is showing up, however the default image does not show for those posts without a custom image.
Thanks in advance for your thoughts!
Emma
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘get_post_meta default image’ is closed to new replies.