Get links and featured image from a specific category (1 post)

  1. paul.contreras
    Posted 1 year ago #

    I am trying to create a custom slider and add my own links but I am not able to get the featured image of a post to display. Here is my code that I am working with right now.

    <?php $posts = get_posts('category=20&orderby=rand&numberposts=6'); foreach($posts as $post) { ?>
    <?php echo '<li>'; ?>
    <a>" target="_parent"><?php the_title();  wp_get_attachment_image( $attachment->ID, 'full' );?>
    <?php echo '</li>'; ?>

    [above code is partially broken, as it was posted without being marked as code; please review http://codex.wordpress.org/Forum_Welcome#Posting_Code for future posting code]

    This code works by displaying the links randomly but they never display the featured image of a post. Can someone please help out and let me know what i am doing wrong here...

Topic Closed

This topic has been closed to new replies.

About this Topic