Skip to:
Content
Pages
Categories
Search
Top
Bottom

Custom Code after first Post in Topic


  • varma
    Participant

    @evildon

    Hi

    I would like to insert a custom code or eco a shortcode after the first post in a topic. ( or say adsense after first posts)

    I have tried to implement this – https://bbpress.org/forums/topic/displaying-adsense-ads/

    But seems to be not working correctly.

    When posting the code in loop-sing-reply, its getting showing below all replies.

    Anyway to show only after the first posts.

    Hope to get an help soon.

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

  • varma
    Participant

    @evildon

    Ok.. so i found out a way to do it while checking the bbpress functions.

    You can enable the bbpress show lead topic using this function

    http://codex.bbpress.org/bbp_show_lead_topic/

    and then easily add any code to the content-single-topic-lead to display anything after the first post in a thread.

    Is there bad side doing this?


    Robin W
    Moderator

    @robin-w

    nothing bad in doing that

    as bbpress has different custom post types for topic and reply, you could also link to the action bbp_theme_after_reply_content action and put a topic condition on
    something like

    function display_after_topic() {
    	if( get_post_type() == 'topic') {
    	$text="hello mother" ;
    	echo $text;
    	}
    	else {
    	return ;
    	}
    }
    
    add_action ('bbp_theme_after_reply_content', 'display_after_topic') ;

    varma
    Participant

    @evildon

    That’s gud.
    Actually i needed to add a shortcode along with some html customization just after the first post of the topic only.
    How to do that?


    Robin W
    Moderator

    @robin-w

    what shortcode are you trying to add?

    html is easy just echo it in brackets eg

    echo '<br>that was a break<div>a div</div></br>' ;
    
Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.