BuddyBoss Home – Web Support Forums Plugins BuddyBoss Media How to display last 5 tagged photo's in another template

Viewing 12 posts - 1 through 12 (of 12 total)
  • Question

    #42231
    @ignitionmktgny

    Looking to display the last 5 photos for a specific user in a custom template.

    Please assist.

    Answers

    #42237
    @ignitionmktgny

    short codes are fine as well on this one

    #42276
    @ignitionmktgny

    Anyone have anything on this?

    #42292

    Alyssa
    Participant
    @alyssa-buddyboss

    @ignitionmktgny Varun should respond to your support request shortly. Thank you for your patience.

    #42315
    @ignitionmktgny

    thanks – still nothing, tho

    #42420

    Anonymous
    @

    Hello @ignitionmktgny, I will provide the codes today

    Regards

    #42438

    Anonymous
    @

    Hi @ignitionmktgny , you can use [bbm_user_specific_media] shortcode to display

    you can add following codes in your functions.php

    
    add_shortcode( 'bbm_user_specific_media', 'bbm_get_user_media' );
    function bbm_get_user_media($atts){
     global $wpdb;
     $table_name2 = $wpdb->prefix . 'buddyboss_media';
     $blog_id=get_current_blog_id();
     if( !isset($atts['user_id']) || $atts['user_id']=="")
     if( bp_is_user() ) {
            $user_id = bp_displayed_user_id();
        } else {
            $user_id = get_current_user_id();
        }
     $sql = "SELECT * FROM $table_name2 WHERE blog_id=$blog_id AND media_author=$user_id ORDER BY id DESC LIMIT 5";
     $img_results = $wpdb->get_results($sql);
      $default_attr = array(
    	'class'	=> "buddyboss-media-photo",
    	'alt'   => trim(strip_tags( get_post_meta($img->media_id, '_wp_attachment_image_alt', true) )),
    );
     $html='<div class="latest-photo-media"><ul style="list-style-type: none;"><li class="bbmedia-grid-item">';
     foreach($img_results as $img)
     {
      $html.='<a class="buddyboss-media-photo-wrap" id="media-'.$img->media_id.'" href="'.wp_get_attachment_url( $img->media_id ).' " >'.wp_get_attachment_image( $img->media_id, 'thumbnail',$default_attr ).'</a>';
     }
     $html.='</li><ul></div>';
     echo $html;
    }
    ?>
    
    #42566
    @ignitionmktgny

    thank you very much varun

    this displays both the last 5 tagged photo’s

    How do I display
    a) the last 5 that the member uploaded?
    b) the last 5 that were uploaded by my friends?

    #42610

    Anonymous
    @

    Hi @ignitionmktgny, I will suggest to developers to create a widgets of these options, it will be easiler to display them using widgets.

    Regards
    Varun Dubey

    #42621
    @ignitionmktgny

    That I understand will be valuable in the future. What I am looking to understand for a current client (timeline = this week) is how to pull these specific items:

    a) the last 5 that the member uploaded?
    b) the last 5 that were uploaded by my friends?

    I looked through the code sent and cannot isolate the args you are passing to filter for those two sets.

    #42668
    @ignitionmktgny

    looking for a good answer for this @vapvarun

    #42724

    Alyssa
    Participant
    @alyssa-buddyboss

    @ignitionmktgny Varun has given you plenty of code already which is not included in the features of our plugin any beyond our typical support. We need you to do a little legwork as a developer to help your client. You can see in the code above the SQL table is buddyboss_media, then you simply need to add a where clause to select the current user, order by timestamp, then limit to 5. You should be able to get a list of friends using this example: https://codex.buddypress.org/developer/loops-reference/the-members-loop/#code-examples for the second item in your request.

Viewing 12 posts - 1 through 12 (of 12 total)
  • The question ‘How to display last 5 tagged photo's in another template’ is closed to new replies.