Skip to:
Content
Pages
Categories
Search
Top
Bottom

Featuring buddypress site wide recent post on home.php without the widget ?

  • Avatar of Dakoo
    dakoo
    Participant

    @dakoo

    hi

    I am trying to make a theme for photoblog community…

    I want to display site-wide recent posts on the home.php

    How will i be able to do it without using the widgets ?

    Will the following code up into home.php in my theme folder help ?

    <?php $posts = bp_blogs_get_latest_posts( null, $instance['max_posts'] ) ?>
    <?php $counter = 0; ?>

    <?php if ( $posts ) : ?>
    <div class="item-options" id="recent-posts-options">
    <?php _e("Site Wide", 'buddypress') ?>
    </div>
    <ul id="recent-posts" class="item-list">
    <?php foreach ( $posts as $post ) : ?>
    <li>
    <div class="item-avatar">
    <a href="<?php echo bp_post_get_permalink( $post, $post->blog_id ) ?>" title="<?php echo apply_filters( 'the_title', $post->post_title ) ?>"><?php echo bp_core_get_avatar( $post->post_author, 1 ) ?></a>
    </div>
    <div class="item">
    <h4 class="item-title"><a href="<?php echo bp_post_get_permalink( $post, $post->blog_id ) ?>" title="<?php echo apply_filters( 'the_title', $post->post_title ) ?>"><?php echo apply_filters( 'the_title', $post->post_title ) ?></a></h4>
    <?php if ( !$counter ) : ?>
    <div class="item-content"><?php echo bp_create_excerpt($post->post_content) ?></div>
    <?php endif; ?>
    <div class="item-meta"><em><?php printf( __( 'by %s from the blog <a href="%s">%s</a>', 'buddypress' ), bp_core_get_userlink( $post->post_author ), get_blog_option( $post->blog_id, 'siteurl' ), get_blog_option( $post->blog_id, 'blogname' ) ) ?></em></div>
    </div>
    </li>
    <?php $counter++; ?>
    <?php endforeach; ?>
    </ul>
    <?php else: ?>
    <div class="widget-error">
    <?php _e('There are no recent blog posts, why not write one?', 'buddypress') ?>
    </div>
    <?php endif; ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • Avatar of Plrk
    plrk
    Participant

    @plrk

    Why not use the widget?

    Avatar of Dakoo
    dakoo
    Participant

    @dakoo

    that is because i have a very complex interface, where i want to display thumbnails for every post. 20 of them in rows of two etc… So i am not sure if i can change the properties of widgets to accommodate all this…

    Can u confirm ?

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

You must be logged in to reply to this topic.