Quantcast
Channel: EasyEngine Community Forum - Latest posts
Viewing all articles
Browse latest Browse all 12639

Display last n images uploaded within the last 7 days

$
0
0

Hello,

Here is a code to show last n images in member's header, but I would like to display last n images uploaded within the last 7 days for example.
I don't know how to add a time range.
I tried using wp_query with 'date_query' but it doesn't work and I'm not sure if it would be possible to use it with images from rtmedia...

Hope you will help me to find a solution,
Thanks a lot !

add_action( 'bp_after_member_header', 'show_last_n_images', 99 );
function show_last_n_images() {
$n = 10;
if( $user_id = bp_displayed_user_id() ) {
$model = new RTMediaModel();
$results = $model->get( array( 'media_type' => 'photo', 'media_author' => $user_id ), 0, $n );
if( $results ) {?>
<ul>
<?php foreach( $results as $image ) { ?>
<li>
<div class="rtmedia-media" id="rtmedia-media-<?php echo $image->id; ?>">
<a href="<?php echo get_rtmedia_permalink( $image->id ); ?>" title="<?php echo $image->media_title; ?>">
<img src="<?php rtmedia_image( "rt_media_thumbnail", $image->id ); ?>" alt="<?php echo rtmedia_image_alt( $image->id );?>" />
</a>
</div>
</li>
<?php } ?>
</ul>
<?php
}
 }
}

Viewing all articles
Browse latest Browse all 12639

Trending Articles