Skip to:
Content
Pages
Categories
Search
Top
Bottom

Custom Activity feed – need help with code


  • faktanett
    Participant

    @faktanett

    Hi

    I am trying to make a shortcode so I can show last 5 items in activity feed in a widget on front page. My coding skill is proving to be insufficcient though, so I am turning to you guys for help.

    Basically, I need the code to show last 5 items, with no “What’s new?” form, pagniation or anything else. Just those 5 items.

    I hope my question is understandable and doable.

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

  • Henry
    Member

    @henrywright-1

    https://codex.buddypress.org/developer/developer-docs/loops-reference/the-activity-stream-loop/

    This will help. Use “max” to output only the last 5 entries.


    faktanett
    Participant

    @faktanett

    Been looking at that. It could just awell be written in klingon :p

    I tried just copying the defailt loop as a test, and got no output.


    faktanett
    Participant

    @faktanett

    Ok. I have managed to get almost there. One issue though. I cannot for the life of me get my query to show only the 5 last status updates.

    When using the below query, nothing is returned.

    if ( bp_has_activities(‘object=status’) )

    Or am I misunderstanding what “Status” is? (I am assuming it is when you post something in the “What’s new MEMBER?” to your profile)


    faktanett
    Participant

    @faktanett

    also, how do I combine more arguments? say I waht both object and max


    Henry
    Member

    @henrywright-1

    Take the standard loop

    `if ( bp_has_activities( bp_ajax_querystring( ‘activity’ ) ) ) :
    while ( bp_activities() ) : bp_the_activity();

    locate_template( array( ‘activity/entry.php’ ), true, false );

    endwhile;
    endif; `

    If you wanted to output only the last 5 entries you would do this

    `if ( bp_has_activities( bp_ajax_querystring( ‘activity’ ).’&max=5′ ) ) :
    while ( bp_activities() ) : bp_the_activity();

    locate_template( array( ‘activity/entry.php’ ), true, false );

    endwhile;
    endif; `

    If you wanted to combine parameters you would use the “&” character. E.g

    `if ( bp_has_activities( bp_ajax_querystring( ‘activity’ ).’&max=5&scope=mentions’ ) ) :
    while ( bp_activities() ) : bp_the_activity();

    locate_template( array( ‘activity/entry.php’ ), true, false );

    endwhile;
    endif; `

    Hope this helps a litte.


    meg@info
    Participant

    @megainfo

    Hi,

    https://gist.github.com/dzmounir/5405475

    This is short code i was made, you just need to edit or remove some css class for html code.


    faktanett
    Participant

    @faktanett

    Thanks a lot for your help guys. Now I just have to figure out why Object=status returns nothing. I have posted several test status updates to my profile, but still nothing shows

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Custom Activity feed – need help with code’ is closed to new replies.
Skip to toolbar