为bbpres论坛启用精选图片:
第1步:将代码添加到您的functions.php
打开您的主题的functions.php,并在末尾粘贴此代码:
//论坛缩略图
add_theme_support( 'post-thumbnails', array( 'forum' ) );
add_post_type_support('forum', 'thumbnail');
第二步:为bbpress论坛选择一个精选图片
在WordPress的后端去你的bbpress论坛区域。
点击一个论坛,在右上角你会发现一个“精选图片”选项(就像普通帖子一样)。
上传你的图标,例如在50×50像素的大小,然后按保存。
add a "Featured Image" to a forum
//论坛缩略图
add_post_type_support('forum', array('thumbnail'));
function ks_forum_icons() {
if ( 'forum' == get_post_type() ) {
global $post;
if ( has_post_thumbnail($post->ID) )
echo '<a title="' . get_the_title( $_post->ID ) . '" href="' . get_permalink( $_post->ID ) . '">';
echo get_the_post_thumbnail($post->ID,array(48,48),array('class' => 'alignleft forum-icon'));
echo '</a>'; }
}
add_action('bbp_theme_before_forum_title','ks_forum_icons');