我有这个功能来按类别显示图像:
/*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;
}
例如,非常适合在我的存档页面中显示“现在”类别的图像。像这儿
http://www.mepanorama.com/category/now/
但我想在帖子中显示此类别的图像,问题是我的永久链接不包括类别,所以有没有办法从我的面包屑中提取类别名称?