Skip to:
Content
Pages
Categories
Search
Top
Bottom

How Can I Show the Last 10 Forum Posts on Home.php?

  • Avatar of bpisimone
    bpisimone
    Participant

    @bpisimone

    I’ve been trying to copy either the code from the forums or the group forum index into home.php with some modifications with no luck.

    Can anyone help out here?

    The main problems I had were wrong link output, pointing to user profiles instead of the posts.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Avatar of Tore
    Tore
    Participant

    @toregus

    I’m new to BP but I’ve learnt that some things in the code are contextually bound. Something higher up in the hierarchy may be missing.

    I’ll want to do the same thing tho. Can you explain what code you took from where?

    Avatar of bpisimone
    bpisimone
    Participant

    @bpisimone

    @Tore thanks for looking into this.

    Actually what worked best for me was just copying the code from directories/forums/forums-loop onto home.php.

    It does the same output as on the forums, but the actual link will forward to “not found” AND the group that it was posted in is not showing either.

    The link looks like this:

    http://site.com/profile/public/forum/topic/title/

    Instead of this:

    http://site.com/groups/group/forum/topic/title/

    Avatar of danbpfr
    danbpfr
    Participant

    @chouf1

    Try this plugin (works with 1.1)

    http://wordpress.org/extend/plugins/bbpress-latest-discussion/

    number of post and forums can be set in plugin option

    Avatar of bpisimone
    bpisimone
    Participant

    @bpisimone

    Thanks Chouf1, seen it b4, still I’d like to do this without a plugin if possible!

    Avatar of Andy Peatling
    Andy Peatling
    Keymaster

    @apeatling

    You can use the activity stream to pull this information and then filter it.

    <?php if ( bp_has_activities(
    'per_page=10&
    max=10&
    object=groups&
    action=new_forum_topic,new_forum_post'
    ) ) : ?>

    <ul id="activity-list" class="forum-posts">

    <?php while ( bp_activities() ) : bp_the_activity(); ?>

    <li class="<?php bp_activity_css_class() ?>">

    <?php bp_activity_content() ?>

    </li>

    <?php endwhile; ?>

    </ul>

    <?php else: ?>

    <div id="message" class="info">
    <p>No latest forum posts.</p>
    </div>

    <?php endif;?>

    This will list the last 10 forum topics or forum posts site wide.

    Avatar of bpisimone
    bpisimone
    Participant

    @bpisimone

    Oh very interesting approach, thanks Andy!

    though it does not work as intended right now: I’ve got the sitewide activity widget in the sidebar, so whenever I click on a filter as groups, friends etc. your code will change as well and display the latest 10 friendships for example.

    Although the action line should prevent that right, new_forum_topic,new_forum_post?

    Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    Andy,

    I’ve tried using the code loop you’ve given above on my front page, but it doesn’t filter to just show the forum activity.

    It’s showing all the site activity, i.e. the action filter doesn’t seem to be having any effect.

    Any thoughts?

    Are you using BP 1.1.3 Roger? It might only work on BP 1.2.

    Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    Hi Paul,

    yes… we are on 1.1.3

    Andy’s post was 3 months ago, so I assume the code loop / bp_has_activities call was for a 1.1.x version, rather than the forthcoming 1.2.

    Any other thoughts?

    Cheers, Roger

    Avatar of bpinspire
    bpinspire
    Participant

    @bpinspire

    @Rogercoathup have you figure out the activities loop for 1.2 by chance?

    Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    @bpinspire – Hi, no I haven’t tried upgrading that theme to 1.2, so not sure whether the activities loop is now working. We are building a new site at the moment, but that will aggregate its forum content from an RSS feed from ‘external’ forums implemented using SimplePress

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

You must be logged in to reply to this topic.