WordPress.org

Forums

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

  1. paul.contreras
    Member
    Posted 10 months 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' );?>
    </a>
    <?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...
    Thanks

Reply

You must log in to post.

About this Topic

  • RSS feed for this topic
  • Started 10 months ago by paul.contreras
  • This topic is not resolved
  • WordPress version: 3.9.1