Skip to:
Content
Pages
Categories
Search
Top
Bottom

Get activity item title – best option


  • Shmoo
    Participant

    @macpresss

    What is the best option to get the title of an activity item?

    I made this.

    
    <?php
    $activity_item_title = get_post( bp_get_activity_secondary_item_id() );
    $activity_item_title = $activity_item_title->post_title;
    ?>
    ...
    <?php echo $activity_item_title; ?>
    ...
    

    Or should I get the action column in the wp_bp_activity database table. This is a string glued all together from multiple parts and start stripping/trimming everything around the title.

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

  • Henry Wright
    Moderator

    @henrywright

    get_post() will get a WordPress post from the wp_posts table. This is different to a BuddyPress activity item which is stored in the wp_bp_activity table.


    Shmoo
    Participant

    @macpresss

    True, but because the content I’m after is all glued together as one solid string inside the action column I have to fish in other database tables to get the content relative to the item. Nothing is saved separately in the wp_bp_activity table.

    But the Primary or Secondary item ID of an activity item always matches the ID in the wp_post table depending on what you’re after.

    I just don’t know what impact this will have on overal performance when I go wish in other tables for content.


    Henry Wright
    Moderator

    @henrywright

    I just don’t know what impact this will have on overal performance when I go wish in other tables for content.

    It depends. WordPress and BuddyPress do a great job when it comes to optimising queries but there are things that will cause a big site to simply fall over (the meta_value column isn’t indexed for example so meta querying could be problematic).


    Shmoo
    Participant

    @macpresss

    Thanks,

    I’ve been testing the get_post() option and the overal number of queries stay the same in the debug bar.


    r-a-y
    Keymaster

    @r-a-y

    The title should already be saved in activity meta.

    $title = bp_activity_get_meta( bp_get_activity_id(), 'post_title' );

    This is assuming that the activity item you are checking for is from a blog post.


    Shmoo
    Participant

    @macpresss

    No I’m busy focussing on the bbPress items for starters, topics and replies as of now.

    I have disabled all activity_items to the stream by default except topics and replies. I want to add more items but one at a time and controlled. A BuddyPress site can become overkill feature wise very fast because everything is so connected and relative with each other.

    Topics and replies in the stream.

    View post on imgur.com

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar