In short, Im not a master of PHP yet and Im not entirely sure how to place a series of checks (if statements) in my template so that it will know what to display depending on what the client uploads/fills out in the CPT ive created...
What Im trying to have it do is:
(1) Check to see if there is a URL entered (custom meta box) - if so, display it and wrap it around the featured image...
(2) If no URL is chosen - then only display the featured image by itself...
(3) and lastly, if no banner image is created at all - then display a default image....
Thanks for the help!
Here is what I have thus far which is currently not working:
<?php if (get_post_meta($post->ID, 'meta_box_topbanner_url', true))?>
<a href="<?php echo get_post_meta ($post->ID, 'meta_box_topbanner_url', true); ?>" target="_blank">
<?php the_post_thumbnail('top-banner-img', array('class' => 'top-banner-img', 'title' => '')); ?>
</a>
<?php elseif the_post_thumbnail('top-banner-img', array('class' => 'top-banner-img', 'title' => '')); ?>
<?php else '<img src="images/epr_bannder_default.jpg" alt="epr_bannder_default" width="960" height="200" />' ?>
elseif
but like I said I just pieced this together the best I could without knowing the correct conventions for writing it.get_post_meta()
, etc.