Skip to:
Content
Pages
Categories
Search
Top
Bottom

distinguish between original post and replies


  • Roger Coathup
    Participant

    @rogercoathup

    How can I distinguish between the original post and replies, when viewing a topic?

    The default template setup (single-topic.php) displays both the original post and the replies using a single loop (loop-replies.php).

    Is there an alternative template part / function that allows us to isolate the original post from the replies to that post?

    [aside: it’s somewhat confusing that bbPress treats the original post on a topic as a reply. What’s the logic behind that?]

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

  • Roger Coathup
    Participant

    @rogercoathup

    ok.. inside the loop (bhp_replies), I can use the WP function get_post_type:

    get_post_type( bbp_get_reply_id() )

    Which will return topic, reply accordingly. Is this the best way to do this?


    stevendaily
    Participant

    @stevendaily

    Thanks very much for posting your solution, Roger. I had the exact same frustration. And no, I found no better way to do this. I had tried using $post->post_type but that gave unexpected results.

    You can also use https://codex.bbpress.org/bbp_show_lead_topic/ it is what is used here on bbpress.org to seperate the topic from the replies using different template parts.

    Take a look at content-single-topic-lead.php, you will also see bbp_show_lead_topic() in various other template parts such as the ones you originally mentioned.

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