Skip to:
Content
Pages
Categories
Search
Top
Bottom

Close topic label


  • enkoes
    Participant

    @enkoes

    Hi, can we add a label something like “[Closed]” BESIDE the topic title in the topic list if the topic is closed for discussion?

    Currently those closed topics will be highlighted pink by default by bbp Style Pack plugin (Topic/Reply Display > item 4). I wonder how can we disable this highlight effect using CSS. “[Closed]” label just looks nice & neat for me.

    Regards.

Viewing 25 replies - 1 through 25 (of 29 total)

  • Robin W
    Moderator

    @robin-w

    should be doable – let me think about this …….


    Robin W
    Moderator

    @robin-w

    I’ll add this functionality to style pack in a few days, but in the meantime

    add_filter ('the_title' , 'rew_add_close_to_topics') ;
    
    function rew_add_close_to_topics ($title) {
    	if ( bbp_is_topic_closed()) {
    		$closed = '[Closed]' ;
    		$sep = ' ' ;
    		$position = 'after' ;
    		if (($position == 'before') && !str_contains($title, $closed)) $title = $closed.$sep.$title ;
    		if (($position =='after') && !str_contains($title, $closed)) $title = $title.$sep.$closed ;
    	}
    return $title ;	
    }

    and amend words/position etc. as you wish.

    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

    and change the background of the closed block to match your theme


    enkoes
    Participant

    @enkoes

    Thank you so much, Robin!

    Two more things to make it perfect:
    1) to disable the default font highlight & grey-out effect;
    2) to change font colour [Closed] to red to make it stands out the rest.

    Regards.


    enkoes
    Participant

    @enkoes

    I notice that [Closed] label appears beside forum name as well:

    See screenshot:
    https://paste.pics/N3JIW

    We need to get rid of it also.

    Regards.


    Robin W
    Moderator

    @robin-w

    ok, so that approach will not work, I was hooking to a wordpress filter, but it is used in too many places.

    I’ll re-think


    wpturk
    Participant

    @wpturk

    You can use

    add_action ('bbp_theme_before_topic_title' , 'rew_add_close_to_topics', 15);


    enkoes
    Participant

    @enkoes

    Hi, do u mean we replace
    add_filter ('the_title' , 'rew_add_close_to_topics') ;

    with
    add_action ('bbp_theme_before_topic_title' , 'rew_add_close_to_topics', 15);?


    wpturk
    Participant

    @wpturk

    No, you can not use the same snippet, since these are different hooks. You can use:

    function rew_add_close_to_topics () {
    
            if ( bbp_is_topic_closed()) {
                    echo '[Closed] ' ;
            }
    }
    add_action ('bbp_theme_before_topic_title' , 'rew_add_close_to_topics', 15);

    enkoes
    Participant

    @enkoes

    Hi, thanks a lot! … feel amazed to see how coding can do the changes to our forum layout.

    This code just works fine in topic listing page.

    For topic page, it would be perfect if user can still see the [Closed] label beside the topic title.
    See https://paste.pics/N5WS0

    Regards.


    wpturk
    Participant

    @wpturk

    Hi, I am glad the code helped you.

    To attach label to the topic title on the topic page, you can try @robin ‘s code with a minor change. (below) This may not work in all themes since the title is coming from a template file.

    function rew_add_close_to_the_topics ($title) {
    
            if ( bbp_is_topic_closed()) {
                    $closed = '[Closed]' ;
                    $sep = ' ' ;
                    $position = 'after' ;
                    if (($position == 'before') && !str_contains($title, $closed)) $title = $closed.$sep.$title ;
                    if (($position =='after') && !str_contains($title, $closed)) $title = $title.$sep.$closed ;
            }
    return $title ;
    }
    add_filter ('single_post_title' , 'rew_add_close_to_the_topics');

    enkoes
    Participant

    @enkoes

    You’re right. This code does not work in my theme. Well, think we just put this part on hold first.

    Next, I want to change font label [Closed] to RED colour. Can we do that?

    Regards.


    wpturk
    Participant

    @wpturk

    Here we go:

    function rew_add_close_to_topics () {
    
            if ( bbp_is_topic_closed()) {
                    echo '<span style="color:red">[Closed]</span> ' ;
            }
    }
    add_action ('bbp_theme_before_topic_title' , 'rew_add_close_to_topics', 15);

    enkoes
    Participant

    @enkoes

    Yes. It’s done beautifully. Thanks!

    One last closed topic customization job: to DISABLE the default font highlight & grey-out effect if the topic is closed. Hope this is not as tricky as it may appear.

    See screenshot:
    https://paste.pics/N8U5T

    Regards


    enkoes
    Participant

    @enkoes

    Hi, I recently saw this topic and it helps me solve one problem.

    I can finally use this CSS to disable the grey-out effect when the topic is closed:

    #bbpress-forums .status-closed,
    #bbpress-forums .status-closed a {
    color: #000 !important;
    }

    From this previous topic also, CSS can do equally well to add [Closed] label beside the closed topic title in topic list page:

    #bbpress-forums .status-closed > li.bbp-topic-title > a.bbp-topic-permalink:after {
    	content: "[Closed]";
    	text-shadow: 1px 1px 0 #ffffff;
    	color: #ff0000;
    	margin-right: 5px;
    }

    I wonder if we can use CSS (instead of PHP codes) to add another [Closed] label beside the topic title in single topic page. Any solution?
    See https://paste.pics/N5WS0

    Also, I’m still searching for ways to disable the defaulted pink font highlight when the topic is closed. Hope somebody can help.
    See https://paste.pics/N8U5T

    Regards.


    Robin W
    Moderator

    @robin-w

    if you are using bbp-styler-pack, the the backgorund is set in

    dashboard>settings>bbp style pack>Topic/Reply Display item 4


    enkoes
    Participant

    @enkoes

    Iā€™m looking for a transparent background (Topic/Reply Display item 4) since I have already set two different colours for odd & even forum listing background (Forum Index Styling > Forum Content > Background Color).

    If I use single colour in Topic/Reply Display item 4, this colour will be visible in either odd/even forum background settings.


    Robin W
    Moderator

    @robin-w

    put this in the style pack custom css or your theme’s custom css

    #bbpress-forums .status-closed, #bbpress-forums .status-closed a {
    	background-color: none !important;
    }

    enkoes
    Participant

    @enkoes

    Thanks Robin.

    The CSS seems not working. The highlight is still visible for closed topic.


    Robin W
    Moderator

    @robin-w

    need a link to a live example on your site


    enkoes
    Participant

    @enkoes

    Here is my site link.


    Robin W
    Moderator

    @robin-w

    ok, that’s your site, but where is a closed topic?


    enkoes
    Participant

    @enkoes

    With [Closed] label one. šŸ™‚


    Robin W
    Moderator

    @robin-w

    sorry, I’m not going to keep clicking forums to try and find one, either give me one or I’ll give up


    enkoes
    Participant

    @enkoes

    Hi, these two topics are closed:
    https://paste.pics/NKT55


    Robin W
    Moderator

    @robin-w

    which forum !!!!!

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