Link post thumbnail using metadata
-
I’m working on a site and the client wants to be able to add logos to the footer that link to external websites. I set it up so only post thumbnails display in the footer. I’m having trouble getting the thumbnail to link to a custom URL that’s saved in wordpress custom fields metadata called “footer_url”. Any idea what Im doing wrong or possibly have a better way of setting this up?
<?php $footer_url = get_post_meta('footer_url'); $thumbnails = get_posts('category_name=footer-logos&showposts=4'); foreach ($thumbnails as $thumbnail) { if ( has_post_thumbnail($thumbnail->ID)) { echo '<div class="footer-logo">'; echo '<a href="' . $footer_url . '">'; echo get_the_post_thumbnail($thumbnail->ID, 'thumbnail'); echo '</a>'; echo '</div>'; } } ?>
- The topic ‘Link post thumbnail using metadata’ is closed to new replies.