Skip to:
Content
Pages
Categories
Search
Top
Bottom

Creating Forum Widget and Links Won't Work

  • @sclough

    Participant

    I’ve created a widget to show the latest posts in the forums, but it doesn’t work completely and I cannot understand why. I’ve looked at the theme files and I am still confused. The widget renders everything correctly except that the perma links to topics are broken. From browsing the code it seems like that is because the BP_GROUPS_SLUG is not set, but I would think the same is the case for the forums page of the default install which renders things just fine. Can anyone help me get the permalink correct? Here is the code from the widget that renders the posts:

    global $forum_template, $bp;

    if ( bp_has_forum_topics(‘type=newest&per_page=’ . $limit) ) {

    echo ‘<ul class=”latest_form_topics_widget”>’;

    while ( bp_forum_topics() ) {

    bp_the_forum_topic();

    echo ‘<li class=”forum_topic_widget”>‘ . bp_get_the_topic_title() . ‘ ‘;

    }

    echo ”;

    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • @sclough

    Participant

    Sorry, here’s repost of the code. $limit come from the widget setting how many posts can show…

    global $forum_template, $bp;

    if ( bp_has_forum_topics('type=newest&per_page=' . $limit) ) {
    echo '<ul class="latest_form_topics_widget">';
    while ( bp_forum_topics() ) {
    bp_the_forum_topic();
    echo '<li class="forum_topic_widget"><a href="' . bp_get_the_topic_permalink() . '" title="' . bp_get_the_topic_title() . '">' . bp_get_the_topic_title() . ' </a></li>';
    }
    echo '</ul>';
    }

    @sclough

    Participant

    I never found a solution to this using the bp function calls. I just wrote a custom query joining the tables that returned the data to build the correct links.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Creating Forum Widget and Links Won't Work’ is closed to new replies.
Skip to toolbar