View Single Post
  #1  
Old 10-13-2012, 10:25 PM
sundance sundance is offline
Registered User
Genesis Member
 
Join Date: Nov 2011
Posts: 66
Default Image by category

Hi, I found this great function on this forum :

Quote:
/*default thumbnails for posts if no thumbnail is set, based on the selected category*/
add_filter('genesis_get_image', 'default_thumb');
function default_thumb($output) {
if(!$output) {
$default_cat_thumbs = array(
'now' => 'now.jpg',
'news' => 'Volleyball-Club_Leipzig.gif');
foreach((get_the_category()) as $category) {
if (array_key_exists($category->slug, $default_cat_thumbs)) {
$url = 'http://www.mepanorama.com/wp-content/images/'.$default_cat_thumbs[$category->slug];
$output = '<img width="120" height="140" src="'.$url.'" class="alignleft" alt="" title="" />';
}
}
}
return $output;
}
works great to show images in my archive page for category "now" for example. like here

http://www.mepanorama.com/category/now/

but i want to show image for this category in posts, the problem is that my permalink does not include category , so is there is a way to pull the category name lets say from my breadcrumb?

example post
http://www.mepanorama.com/180193/test/