Wordpress display featured posts outside of loop
Posted
by Thomas
on Stack Overflow
See other posts from Stack Overflow
or by Thomas
Published on 2010-04-15T15:41:10Z
Indexed on
2010/04/15
15:43 UTC
Read the original article
Hit count: 343
Im new to WP and Im not real sure how to work with the loop. I am trying to display featured posts in the sidebar with this code:
<?php
query_posts('cat=5');
$url = get_permalink();
while(have_posts()){
the_post();
$image_tag = wp_get_post_image('return_html=true');
$resized_img = getphpthumburl($image_tag,'h=168&w=168&zc=1');
$title = $post->post_title;
echo "<ul class='left_featured'>";
echo "<li><a href='";
echo $url;
echo "'><img src='$resized_img' width='168' height='168' ";
echo "'/></a></li>";
echo "<li><a href='";
echo $url;
echo "'/>";
echo $title;
echo "</a></li></ul>";
echo "";
};
?>
This gives me all sorts of crazy outputs, text from random posts, images, etc...Its supposed to output a list of images and titles for all of the posts in a certain category. Any help would be really appreciated.
Oh yeah, I am using a plugin that resizes images on the fly, thats what the the wp_get_post_image/getphpthumburl business is.
© Stack Overflow or respective owner