• Peyton

    (@peytongregory)


    I have a portfolio section on a website. It’s a bunch of post thumbnails and nothing else. When you click on the thumbnails the go to their post.

    What i want to be able do is –

    Create a blog post, give the post a title, thumbnail image, select the correct post category, and type in a url (custom field, post meta, not sure whats the best way)

    On the portfolio page when you hover over an image i want the Post title and the custom link to appear.

    I’ve got everything done but creating the custom link part. What would be the best way to do this?

    Below is a sloppy variation of what i’m working with.

    <?php
        $thumbnails = get_posts('category_name=portfolio-web&numberposts=20');
        foreach ($thumbnails as $thumbnail) {
        if ( has_post_thumbnail($thumbnail->ID)) {
    	echo '<div class="portfolio-thumb-box">';
        echo '<a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '" >';
        echo get_the_post_thumbnail($thumbnail->ID, 'thumbnail');
    	echo '<div class="visit-site-btn">Visit Website</div>';
        echo '</a>';
    	echo '</div>';
        }
        }
        ?>
  • The topic ‘Post thumbnail link to external websites’ is closed to new replies.