1

So, been racking my brain about this. Basically I need to display the activity feed of a specific group in a page template. I have this code (copied activity loop.php) to work to display all group activity, but would like to filter based on group id. Any thoughts why this does not show specific group activity?

thanks

<div style="overflow: auto;display: block;clear: both">
<?php do_action( 'bp_before_activity_loop' ); ?>

<?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . '&object=groups&action=activity_update&primary_id=12' ) ) : ?>

    <?php /* Show pagination if JS is not enabled, since the "Load More" link will do nothing */ ?>
    <noscript>
        <div class="pagination">
            <div class="pag-count"><?php bp_activity_pagination_count(); ?></div>
            <div class="pagination-links"><?php bp_activity_pagination_links(); ?></div>
        </div>
    </noscript>

    <?php if ( empty( $_POST['page'] ) ) : ?>

        <ul id="activity-stream" class="activity-list item-list">

    <?php endif; ?>

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

<li class="<?php bp_activity_css_class(); ?>" id="activity-<?php bp_activity_id(); ?>">
    <div class="activity-avatar">
        <a href="<?php bp_activity_user_link(); ?>">

            <?php bp_activity_avatar("type=full"); ?>

        </a>
    </div>

    <div class="activity-content">

        <div class="activity-header">

            <?php bp_activity_action(); ?>

        </div>

        <?php if ( bp_activity_has_content() ) : ?>

            <div class="activity-inner">

                <?php bp_activity_content_body(); ?>

            </div>

        <?php endif; ?>

        <?php do_action( 'bp_activity_entry_content' ); ?>

        <div class="activity-meta">

            <?php if ( bp_get_activity_type() == 'activity_comment' ) : ?>

                <a href="<?php bp_activity_thread_permalink(); ?>" class="button view bp-secondary-action" title="<?php esc_attr_e( 'View Conversation', 'buddypress' ); ?>"><?php _e( 'View Conversation', 'buddypress' ); ?></a>

            <?php endif; ?>

            <?php if ( is_user_logged_in() ) : ?>

                <?php if ( bp_activity_can_comment() ) : ?>

                    <a href="<?php bp_activity_comment_link(); ?>" class="button acomment-reply bp-primary-action" id="acomment-comment-<?php bp_activity_id(); ?>"><i class="fa fa-comments"></i> <?php echo bp_activity_get_comment_count(); ?></a>

                <?php endif; ?>

                <?php if ( bp_activity_can_favorite() ) : ?>

                    <?php if ( !bp_get_activity_is_favorite() ) : ?>

                        <a href="<?php bp_activity_favorite_link(); ?>" class="button fav bp-secondary-action" title="<?php esc_attr_e( 'Mark as Favorite', 'buddypress' ); ?>"><i class="fa fa-thumbs-o-up"></i></a>

                    <?php else : ?>

                        <a href="<?php bp_activity_unfavorite_link(); ?>" class="button unfav bp-secondary-action" title="<?php esc_attr_e( 'Remove Favorite', 'buddypress' ); ?>"><i class="fa fa-thumbs-up"></i></a>

                    <?php endif; ?>

                <?php endif; ?>

                <?php
                // LET's CHANGE THE BUDDYPRESS BUTTON CONTENT WITH AN ICON
                if ( bp_activity_user_can_delete()) :
                $url   = bp_get_activity_delete_url();
                $class = 'delete-activity';
                // Determine if we're on a single activity page, and customize accordingly
                if ( bp_is_activity_component() && is_numeric( bp_current_action() ) ) {
                  $class = 'delete-activity-single';
                }
                echo '<a href="' . esc_url( $url ) . '" class="button item-button bp-secondary-action ' . $class . ' confirm" rel="nofollow"><i class="fa fa-trash-o"></i></a>'; 

                endif; ?>

                <?php do_action( 'bp_activity_entry_meta' ); ?>

            <?php endif; ?>

        </div>

    </div>

    <?php do_action( 'bp_before_activity_entry_comments' ); ?>

    <?php if ( ( bp_activity_get_comment_count() || bp_activity_can_comment() ) || bp_is_single_activity() ) : ?>

        <div class="activity-comments">

            <?php bp_activity_comments(); ?>

            <?php if ( is_user_logged_in() && bp_activity_can_comment() ) : ?>

                <form action="<?php bp_activity_comment_form_action(); ?>" method="post" id="ac-form-<?php bp_activity_id(); ?>" class="ac-form"<?php bp_activity_comment_form_nojs_display(); ?>>
                    <div class="ac-reply-avatar"><?php bp_loggedin_user_avatar( 'width=' . BP_AVATAR_THUMB_WIDTH . '&height=' . BP_AVATAR_THUMB_HEIGHT ); ?></div>
                    <div class="ac-reply-content">
                        <div class="ac-textarea">
                            <textarea id="ac-input-<?php bp_activity_id(); ?>" class="ac-input bp-suggestions" name="ac_input_<?php bp_activity_id(); ?>"></textarea>
                        </div>
                        <input type="submit" name="ac_form_submit" value="<?php esc_attr_e( 'Post', 'buddypress' ); ?>" /> &nbsp; <a href="#" class="ac-reply-cancel"><?php _e( 'Cancel', 'buddypress' ); ?></a>
                        <input type="hidden" name="comment_form_id" value="<?php bp_activity_id(); ?>" />
                    </div>

                    <?php do_action( 'bp_activity_entry_comments' ); ?>

                    <?php wp_nonce_field( 'new_activity_comment', '_wpnonce_new_activity_comment' ); ?>

                </form>

            <?php endif; ?>

        </div>

    <?php endif; ?>

    <?php do_action( 'bp_after_activity_entry_comments' ); ?>

</li>

    <?php endwhile; ?>

    <?php if ( bp_activity_has_more_items() ) : ?>

        <li class="load-more">
            <a href="#more"><?php _e( 'Load More', 'buddypress' ); ?></a>
        </li>

    <?php endif; ?>

    <?php if ( empty( $_POST['page'] ) ) : ?>

        </ul>

    <?php endif; ?>

<?php else : ?>

    <div id="message" class="info">
        <p><?php _e( 'Sorry, there was no activity found. Please try a different filter.', 'buddypress' ); ?></p>
    </div>

<?php endif; ?>

<?php do_action( 'bp_after_activity_loop' ); ?>

<?php if ( empty( $_POST['page'] ) ) : ?>

    <form action="" name="activity-loop-form" id="activity-loop-form" method="post">

        <?php wp_nonce_field( 'activity_filter', '_wpnonce_activity_filter' ); ?>

    </form>

<?php endif; 
//echo do_shortcode('[activity-stream object=groups primary_id=3]'); ?>

</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.