Skip to:

Topic tooltips

  • Hi,

    A themes front page usually displays the latest discussions, but with many forums there is no context to each topic listed so the topic title is often meaningless. E.g. a topic title of ‘Help’ does not invite the viewer to click the topic to see the posts.

    I’d like to add a title=”first part of post…’ attribute to the <tr> tag of each topic in the list.

    I tried adding a filter to topic_class(), to fudge class=”xx” to class=”xx” title=”yy” but alt_class() has no filters. My other approach was to add a new function to the theme, e.g. in kakumei

    <tr<?php topic_class(); topic_tooltip(); ?>>

    and in functions.php

    function topic_tooltip() {
    $topic_id = get_topic_id();
    echo ' title="'.$topic_id.'"';

    but I’m struggling to work out how to get the current post available to display an extract of the first post of the topic.

    Any help really appreciated.


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

  • Ben L.


    function topic_tooltip() {
    $topic_id = get_topic_id();
    $post = bb_get_first_post( $topic_id );
    $post_content = strip_tags( get_post_text( $post ) );
    // Do something to $post_content to make it short here
    echo ' title="', esc_attr( $post_content ), '"';


    Thanks for the response.

    I tried as suggested but I always get the post content of

    First post W00t!

    The topic_id passed is different each time, but it always returns the post content for topic id 1.

    I’ve written a few WordPress plugins, but the lack of comments and documentation in the bbpress code is making it hard to work out what populates the global topics and posts variables.

    How do I get a post given a topic ID ?

    EDIT: Just worked out I need get_post_text( $post->post_id ) !



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