Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum name on topic title


  • acb93
    Participant

    @acb93

    Hi everyone. In this moment I am using the “last topics” box in the main page of my website:

    La comunidad con el mejor contenido sobre gaming y eSports

    I am using the shortcode [bbp-topic-index]

    Now is all OK, the topic title appears OK etc.

    But I want to implement something like this in this shortcode: Forum name: Topic title

    I want the Forum name before Topic title (only in the “last topics shortcode”)

    How I can do it? Maybe I need to modify the loop-topics.php file?

    Thanks in advance.

    Regards.

    Adrià Calendario.

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

  • Robin W
    Moderator

    @robin-w

    hmm… that’s not easy as you rightly say the hierarchy is

    content-archive-topic
    loop-topics
    loop-single-topic

    This last one is also used by forums, so you can’t just change that.

    In this last you could hook an action to ‘bbp_theme_before_topic_title’ eg put this in your child theme functions file

    add_action ('bbp_theme_before_topic_title' ,'rew_display_forum' ) ;
    
    function rew_display_forum () {
    	$topic_forum_id = bbp_get_topic_forum_id();
    	$forum_title = bbp_get_forum_title( $topic_forum_id);
    	echo '<div class="rew-forum-name">'.$forum_title.'</div>' ;
    }

    and then as the shortcode displays in a ‘page’ class and the forums in a ‘forum’ class, we can add css to hide the forum title unless we are in a page

    so in your custom css area put

    .rew-forum-name {
    display :none ;
    }
    .page .rew-forum-name {
    display : inline-block ;
    }	

    that should work


    acb93
    Participant

    @acb93

    Thanks for the answer!

    Is working well but… Can I put the “link” on the forum name? So if I click it goes to the forum.

    Regards.

    Adrià Calendario.


    Robin W
    Moderator

    @robin-w

    add_action ('bbp_theme_before_topic_title' ,'rew_display_forum' ) ;
    
    function rew_display_forum () {
    	$topic_forum_id = bbp_get_topic_forum_id();
    	$forum_title = bbp_get_forum_title( $topic_forum_id);
    	$forum_url = bbp_get_forum_permalink( $topic_forum_id );
    	echo '<a class="rew-forum-name" href="'.$forum_url.'">'.$forum_title.': </a>' ;
    }

    acb93
    Participant

    @acb93

    WOW!

    Thank you for the support!

    I am going to donate you right now. For sure.

    Regards.

    Adrià Calendario.


    Robin W
    Moderator

    @robin-w

    Thank you so much for your kind donation – it is really appreciated !!

    I am glad to have helped 🙂

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