Get links and featured image from a specific category
-
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
- The topic ‘Get links and featured image from a specific category’ is closed to new replies.