Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to get the title of the topic from the ID of the reply.

  • @kanonkanonka

    Participant

    Please tell me the code to get the title of the topic from the ID of the reply.

    I wrote the following code, but it will not work on loading with Ajax.

    Specifically, bbp_get_reply_topic_id does not seem to work.

    What am I gonna to do?

    function my_echo_topicTitle_from_replyId( $replyId ) {
    	$topicId = bbp_get_reply_topic_id( $replyId );
    	$page = get_page( $topicId );
    	$slug = $page->post_name;		
    	$topicTitle = get_the_title( $topicId );
    	echo '<div class="topic_title"><a href="http://example.com/topic/'.$slug.'">'.$topicTitle.'</a></div>'; 
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • @robin-w

    Moderator

    function bbp_get_reply_topic_title ($reply_id)

    @kanonkanonka

    Participant

    Thank you.
    But that code does not work with Ajax as well.
    The topic title is displayed at first, but after Ajax the title of the reply will be displayed.
    The same is true for bbp_get_reply_topic_id.

    @kanonkanonka

    Participant

    By the way, the following code to display “Comment, Reply, Topic create” works even after Ajax.

    function my_echo_activity_type( $replyId ){
    	$posttype = get_post_type( $replyId );	
    	$replyToId = bbp_get_reply_to( $replyId );
    	if( $posttype == 'topic' ){
    		echo '<span class="type">Topic create</span>';
    	}
    	elseif( $posttype == 'reply' && $replyToId != '0' ){
    		echo '<span class="type">Reply</span>';
    	}
    	elseif( $posttype == 'reply' && $replyToId == '0' ){
    		echo '<span class="type">Comment</span>';
    	}
    }

    @kanonkanonka

    Participant

    Is there anyone who can give me a hand?

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