I'm trying to show some Wordpress category thumbnails on my homepage, but it seems my code is breaking the rest of my site. It kills the page and anything under my code won't load.
Any help would be appreciated on how to get this working.
Thanks!
<?php
global $post;
$temp_post = $post;
$args = array('numberposts' => 1, 'category' => 40, 'orderby' => 'date', 'order' => 'DESC');
$posts = get_posts($args);
foreach ($posts as $post) : setup_postdata($post);
if (has_post_thumbnail()) {
$thumbnail = get_post_thumbnail($post->ID, 'thumbnail');
$title = get_the_title();
$output = $title . "<br />" . $thumbnail;
}
endforeach;
$post = $temp_post;
wp_reset_postdata();
return($output);
?>
EDIT
<?php
global $post;
$temp_post = $post;
$args = array('numberposts' => 6, 'category' => 227, 'orderby' => 'date', 'order' => 'DESC');
echo '<div class="categoryThumbnailList">';
$posts = get_posts($args);
foreach ($posts as $post) : setup_postdata($post);
if (has_post_thumbnail()) {
$thumbnail = get_the_post_thumbnail($post->ID, 'thumbnail');
$link = get_permalink($post->ID);
$title = get_the_title();
echo '<div class="categoryThumbnailList_item">';
echo '<a href="' .$link . '" title="' .$title . '">' .$thumbnail . '</a><br/>';
echo '<a href="' .$link . '" title="' .$title . '">' .$title . '</a>';
echo '</div>';
}
endforeach;
echo '</div>';
echo '<div class="categoryThumbnailList_clearer"></div>';
$post = $temp_post;
wp_reset_postdata();
?>
get_post_thumbnail(), not a category thumbnail. Are you using a plugin to set up category thumbnails? That would be a useful piece of information. – mrwweb May 5 '12 at 20:01get_the_post_thumbnail()- I forgotthe– McGuyverr May 5 '12 at 20:12the_posts()- But my code takes place of the regular blog posts. How can I fix that? – McGuyverr May 5 '12 at 20:57