Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm buiding a site that lists the most recent posts on the front page, the site is a recompilation of interesting articles and images so it doesn't make sense to link to the individual post.

I currently have the title redirecting externally to the link, but I would also like to link externally via the post image.

I've set up a custum field "externalurl"

This is what I have so far in the loop.php which does not work:

    <?php
    if ( has_post_thumbnail() ){ ?>
        <?php $thumbURL = get_post_custom_values('externalurl'); ?>
        <a href="<?php echo get_attachment_link($thumbURL); ?>" rel="gallery" title="<?php the_title(); ?>">        
            <?php the_post_thumbnail(); ?>
            <span class="view-large"></span>
        </a>
    <?php } ?>

Does anybody have any idea what I'm doing wrong? Any suggestions welcome.

Thanks in advance!

share|improve this question
add comment

1 Answer

http://codex.wordpress.org/Function_Reference/get_post_meta

wouldn't echoing get_post+meta in the a link be best?

<a href="<?php echo get_post_meta($post->ID, "externalurl", true) ); ?>" rel=...and so on
share|improve this answer
    
Also: be sure to wrap that in esc_url(), e.g. <?php echo esc_url( get_post_meta( $post->ID, 'externalurl', true) ); –  Chip Bennett Aug 12 '11 at 18:26
    
Something I hadn't learned about back in March, thank you!! –  Rev. Voodoo Aug 14 '11 at 10:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.