Skip to:
Content
Pages
Categories
Search
Top
Bottom

Create a link image for last post in forum

  • @frenchlemans

    Participant

    Hello,

    I would like to include an image with link on the last post as on the freshness user with the bbp_forum_freshness_link () function.
    The user can click on the image to read the last post, see my screenshot.

    Thank you for your answers.
    Regards

    image with link

Viewing 15 replies - 1 through 15 (of 15 total)
  • @frenchlemans

    Participant

    Another screenshot

    lastpost

    @robin-w

    Moderator

    So all the same image – yes ?

    @frenchlemans

    Participant

    Hello,

    Yes it will always be the same image.
    Members of my old phpBB forum that I am remaking on bbPress are familiar with this image that I want to reuse on my new bbPress forum.

    When the user clicks on the link it takes them to the last posted message, just as if they were clicking on the date and time.

    @robin-w

    Moderator

    Put this in your child theme’s function file –

    ie wp-content/themes/%your-theme-name%/functions.php

    where %your-theme-name% is the name of your theme

    or use

    Code Snippets

    
    add_action( 'bbp_theme_after_topic_author', 'rew_freshness_display_image');
    
    function rew_freshness_display_image ($forum_id = 0) {
    	// Verify forum and get last active meta
    	$forum_id  = bbp_get_forum_id( $forum_id );
    		$active_id = bbp_get_forum_last_active_id( $forum_id );
    		$link_url  = $title = '';
    
    		if ( empty( $active_id ) )
    			$active_id = bbp_get_forum_last_reply_id( $forum_id );
    
    		if ( empty( $active_id ) )
    			$active_id = bbp_get_forum_last_topic_id( $forum_id );
    
    		if ( bbp_is_topic( $active_id ) ) {
    			//then reset forum_id to the forum of the active topic in case it is a sub forum
    			$forum_id = bbp_get_topic_forum_id($active_id);
    			$link_url = bbp_get_forum_last_topic_permalink( $forum_id );
    			$title    = bbp_get_forum_last_topic_title( $forum_id );
    		} elseif ( bbp_is_reply( $active_id ) ) {
    			//then reset forum_id to the forum of the active topic in case it is a sub forum
    			$forum_id = bbp_get_reply_forum_id($active_id);
    			$link_url = bbp_get_forum_last_reply_url( $forum_id );
    			$title    = bbp_get_forum_last_reply_title( $forum_id );
    		}
    		
    		$anchor = '<a class="rew_freshness_display_image" href="' . esc_url( $link_url ) . '" title="' . esc_attr( $title ) . '"><img src="http://mysite.com/wp-content/uploads/2013/06/Brauhaus-2.jpg">' . '</a>';
    	
    echo '<p>'.$anchor.'</p>' ;
    }

    and change the <img src="http://mysite.com/wp-content/uploads/2013/06/Brauhaus-2.jpg" /> to the image you want – make sure it is sized right !!

    @frenchlemans

    Participant

    it works great, thanks.

    However, is it possible to have the image under the date as I show on the screenshot?

    Thank you

    screen target

    @robin-w

    Moderator

    are you using style pack? and freshness tab ?

    @frenchlemans

    Participant

    yes !

    website

    @robin-w

    Moderator

    @frenchlemans

    so can you detail the settings in freshness tab please

    @frenchlemans

    Participant

    @ robin-w
    I’m sorry, I don’t understand what you mean by “setting freshness tab”
    where is it ?

    @frenchlemans

    Participant

    @ robin-w
    I’sorry i say a mistake, i don’t have bbp style pack
    I have bbp initial

    @robin-w

    Moderator

    ok,

    the default display order is freshness, followed by author – you have it the other way around.

    try changing the line above

    add_action( 'bbp_theme_after_topic_author', 'rew_freshness_display_image');

    to

    add_action( 'bbp_theme_after_forum_freshness_link', 'rew_freshness_display_image');

    @frenchlemans

    Participant

    Robin W => you are the best of the best
    it’s very good like that.
    A big thank’s for you !!!!

    @robin-w

    Moderator

    no problem – glad you are fixed !

    @frenchlemans

    Participant

    @ robin-w
    Just to show, with the CSS I finished configuring this part

    when finish

    @robin-w

    Moderator

    Great – thanks for posting back – looks smart and glad you are fixed !!

Viewing 15 replies - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.
Skip to toolbar