WordPress.org

Ready to get started?Download WordPress

Forums

Echo out featured post URL (2 posts)

  1. indeliblestain
    Member
    Posted 1 year ago #

    Hi there,

    I'm currently working on a latest post section for the landing page on my website, and I'm having trouble echoing out the URL for the featured image attached to the post.

    Currently I'm using this:

    <?php 
    
    $args = array( 'numberposts' => 1, 'orderby' => 'post_date', 'order' => 'DESC' );
    
    $recent_posts = wp_get_recent_posts( $args );
    
    foreach( $recent_posts as $recent ) { ?>
    
    <div id="featuredblog">
    	<div id="featuredimage">
        	<?php the_post_thumbnail($recent->ID, 'thumbnail'); ?>
        </div>
        <div id="featuredtext">
            <h1 class="h1_post_title"><?php echo $recent["post_title"]; ?></h1>
            <p class="p_post_excerpt"><?php echo $recent["post_excerpt"];?></p>
        </div>
    </div>
    
    <?php } ?>

    It doesn't echo anything out at all. I've tried a number of ways that have been suggested on the forum to no avail. I'm starting to get annoyed with the entire process.

    Any help in resolving this problem would be much appreciated.

  2. indeliblestain
    Member
    Posted 1 year ago #

    Still having trouble with this.

    I'm currently looking through the functions files for the theme I'm using to make sure that the_post_thumbnail is active.

Topic Closed

This topic has been closed to new replies.

About this Topic