BuddyBoss Home – Web › Support Forums › Plugins › BuddyBoss Media › How to display last 5 tagged photo's in another template
- This topic has 11 replies, 3 contibutors, and was last updated 9 years, 4 months ago by Alyssa.
Question
July 6, 2015 at 3:21 pm #42231@ignitionmktgnyLooking to display the last 5 photos for a specific user in a custom template.
Please assist.
Answers
July 6, 2015 at 10:22 pm #42237@ignitionmktgnyshort codes are fine as well on this one
July 7, 2015 at 2:54 pm #42276@ignitionmktgnyAnyone have anything on this?
July 8, 2015 at 8:49 am #42292@alyssa-buddyboss
AlyssaParticipant@ignitionmktgny Varun should respond to your support request shortly. Thank you for your patience.
July 8, 2015 at 6:38 pm #42315@ignitionmktgnythanks – still nothing, tho
July 9, 2015 at 10:36 pm #42420@
AnonymousHello @ignitionmktgny, I will provide the codes today
Regards
July 10, 2015 at 5:55 am #42438@
AnonymousHi @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; } ?>
July 13, 2015 at 9:01 am #42566@ignitionmktgnythank 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?July 14, 2015 at 7:16 am #42610@
AnonymousHi @ignitionmktgny, I will suggest to developers to create a widgets of these options, it will be easiler to display them using widgets.
Regards
Varun DubeyJuly 14, 2015 at 9:12 am #42621@ignitionmktgnyThat 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.
July 14, 2015 at 9:09 pm #42668@ignitionmktgnylooking for a good answer for this @vapvarun
July 15, 2015 at 1:45 pm #42724@alyssa-buddyboss
AlyssaParticipant@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.
- The question ‘How to display last 5 tagged photo's in another template’ is closed to new replies.