Skip to:
Content
Pages
Categories
Search
Top
Bottom

add a "Featured Image" to a forum

  • Hello bbpress gurus,

    First, thanks a lot for this wonderful plugin :)

    Now please forgive my French looking English…

    I’m using bbpress on a site where I’d like to show up on some template page a list of recent posts in the forum. get_posts is my friend and that’s ok.

    But I’d also like to show a nice picture of the categories in which those recent posts where posted. Well, “regular” posts on WP now can have a “Featured Image”. And I looked to add this to my forums as well.

    And I think I made it

    But not sure ^^

    Anyway

    I added this line in bbp-admin/bbp-forums.php :

    add_meta_box(‘postimagediv’, __(‘Featured Image’), ‘post_thumbnail_meta_box’, $this->post_type, ‘side’, ‘low’);

    in function attributes_metabox() (~ l.190)

    And it seems to be working.

    But as far as I can tell, there’s maybe 50% luck this code not doing some very bad things in the same time ^^

    PLease advice, if there is a better way to achieve this…

Viewing 9 replies - 1 through 9 (of 9 total)

  • sxalexander
    Member

    @sxalexander

    This is a bit late, but I think there’s another way to solve this.

    I think the most WordPress-y way to accomplish this is to add the following to your theme’s /functions.php:

    add_post_type_support('forum', array('thumbnail'));

    This will add the featured image metabox to all forums. See here for more details:

    http://codex.wordpress.org/Function_Reference/add_post_type_support

    Hello sxalexander,

    Yes, this is a much better way to do that.

    And it keeps the bbpress plugin unchanged, so it can safely be updated.

    Thanks !


    AAShepAA
    Participant

    @aashepaa

    sxalexander,

    Can you explain further how to implement this in the functions.php – please.


    AAShepAA
    Participant

    @aashepaa

    Bump.


    Marcin Biegun
    Participant

    @biegun

    1. create bbpress directory in your theme directory
    2. copy there loop-single-forum.php from /wp-content/plugins/bbpress/templates/default/bbpress
    3. add wherever you wish the image to appear:
    <?php echo get_the_post_thumbnail($post_id, 'full'); ?>


    Travis
    Participant

    @tjtaylor

    I had to add another line to get this working:

    add_theme_support( 'post-thumbnails', array( 'forum' ) );
    add_post_type_support('forum', 'thumbnail');
    

    Shawn74
    Participant

    @shawn74

    Hello,
    thanks for the tip, it’s working perfectly…now i have a picture before the Forum Title…excatly what i need…

    Anyway i need to know how to edit it’s CSS style…

    I’m using Firebug and i was able to edit the CSS style for the topic’s thumbnails to get identical as the buddypress one…with a circle box as border…
    You should see here hxxp://www.thepanicroom.it/forum/forum/panics-room-forum/

    Unfortunately when i analyze the picture your code added, i have no idea on how to find a CSS line to modify…i get only html div span body etc etc

    I tried to change the class name to ‘Thumbnail’ and i got a perfect thumbnail…. i changed it to Avatar but no result…i also declred it exactly like the Buddypress do…but nothing to do, the picture come back to the default one…

    Please sorry for my really wild and bad english :-)

    Thank you so much…


    Shawn74
    Participant

    @shawn74

    P.s. the working code (at least for me) is the one posted by @aashepaa

    Thanks again…


    Shawn74
    Participant

    @shawn74

    Solved:

    I declared as Avatar then i used this code inside theme’s function php file:

    
    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 get_the_post_thumbnail($post->ID,'thumbnail',array('class' => 'alignleft forum-icon'));
    	 }
    }
    add_action('bbp_theme_before_forum_title','ks_forum_icons');
    

    Then i changed the img.avatar style (hope to have not changed anithing else…)

    Source:
    http://www.kristarella.com/2013/04/bbpress-forum-icons/

Viewing 9 replies - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.