• Resolved peters2007

    (@peters2007)


    I’ve currently got a front page which displays the lead article and then a series of links to the next few articles. It’s a theme that has been self-created.

    I’ve read about the Featured Image feature that was introduced to WordPress recently, but while it’s easy enough to add a Featured Image, I can’t find any documentation about how to actually call/configure the featured image if you’re making your own custom theme (as opposed to using a theme which already uses it).

    For example, if I want to display on the front page the featured image associated with the lead article, what exactly should I be doing?

Viewing 3 replies - 16 through 18 (of 18 total)
  • No problem!

    Hi!
    I have a similar problem to the one above but not sure if it can be solved in the same way.
    I too am simply building my own website using wordpress without much knowledge of CSS or PHP.

    Currently I am using the theme Shaken Grid, which is great for my portfolio site as it uses Colorbox to automatically enlarge all my featured images in a Lightbox style.

    However, I prefer the style and layout to another theme (Paragrams) which doesn’t have this functionality. I’ve installed the Colorbox plugin but it won’t work on Featured Images because this theme automatically links Featured Image thumbnails to the post, instead of to the full size image.

    My question is, is there a way to automatically link Featured Images to the fullsize versions of themselves instead of the post?

    Thanks very much in advance ??

    Hi Chris, this should be doable. Here is a basic loop that worked for me:

    <?php global $post;
    
    	$loop = new WP_Query( array( 'posts_per_page' => 5 ) );
    
    	while ( $loop->have_posts() ) : $loop->the_post();
    
    	$link = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );
    
        echo '<a href="' . $link . '">';
    
    	the_post_thumbnail();
    
    	echo '</a>';
    
    	endwhile; ?>

    You might have to mess around with this and create multiple featured image sizes so that you can load a smaller thumbnail size and link that to a larger version of the featured image.

    There is a bit more info on this post on WordPress Answers.

Viewing 3 replies - 16 through 18 (of 18 total)
  • The topic ‘How to call featured image’ is closed to new replies.