Timeline for Get the 5 lastest Featured Posts from a category
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 28, 2012 at 1:48 | comment | added | fuxia♦ | @presdec Just wait until you can answer. Write a real answer then and mark your question as answered. :) | |
Jul 28, 2012 at 0:46 | comment | added | pcarvalho | i've updated your question as it was our own solution, but feel free to mark my answer if it helped ;) | |
Jul 27, 2012 at 23:40 | comment | added | presdec | It looks a mess in here but apparently i can't answer my own question in under 8 hours :P Feel free to re-post the solution if u want to. | |
Jul 27, 2012 at 23:36 | comment | added | presdec | Thanks for the help. After struggling i managed to get it working. $categoryId = 7; $args = array('category' => $categoryId , 'post_status' => 'publish', 'numberposts' => 5); $posters = get_posts( $args ); if ( $posters ) { foreach ($posters as $post) { $imgsrc = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full"); ?> <a href="<?php echo get_permalink($post->ID); ?>" title=""><img src="<?php echo $imgsrc[0]; ?>" class="thumbnail" width="130" height="130" alt='' /></a> <?php } } I've made it into a shortcode [featuredposts category=7]. | |
Jul 27, 2012 at 20:55 | comment | added | pcarvalho |
yes, having a template is the best way :) why not just use the_post_thumbnail(); inside the foreach loop? or is the loop itself that's not showing your posts?
|
|
Jul 27, 2012 at 20:35 | comment | added | presdec | The problem lies in that the code doesn't work :S I like the conditional idea, but it'd be easier to make a home.php template tbh and might make more sence. I tried adding a count=1 i= etc to have it loop 5 times and then echo the html for each image, but that somehow made the bug way worse... | |
Jul 27, 2012 at 20:06 | history | answered | pcarvalho | CC BY-SA 3.0 |