Display users Albums in custom page template

Hi everybody, is there an easy way to display users albums (by user_id) in a custom page template?

Thanks Vasik

Hi @Vaclav_Greif,

You can use rtMedia gallery shortcode: http://docs.rtcamp.com/rtmedia/features/shortcodes/gallery-shortcode/#album_id in page and can show user albums.

[rtmedia_gallery context=“profile” media_type=“album”]

It will show album gallery of current loggedin user.

Hi @riteshpatel, thanks for reply. I need to pass the user_id as a parameter, as I need to display albums of specific users, not a currently logged in user… Any way for that?

OK, this one was pretty easy in the end:

<?php
$args = array(
    'post_type' => 'rtmedia_album',
    'author'    => $user_id,
    'posts_per_page' => -1,
    'post_status' => array('publish','hidden'),
    ),
);
$posts = get_posts($args);
foreach ($posts as $post) { ?>
    <h3><?php echo $post->post_title; ?></h3>
    <?php
    $album_id = nevestam_get_album_id_by_post_id($post->ID);
    echo do_shortcode('[rtmedia_gallery global="true" media_type="photo" album_id="'.$album_id.'"]');
}
?>

Hello @Vaclav_Greif,

As you want to display list of albums for specific user, you can use below ShortCode:

echo do_shortcode('[rtmedia_gallery global="true" media_type="album" media_author=5]');

Note: Change media_author to whatever user_id you want.

Passing album_id to shortcode will fetch media under that album_id and not the list of media for that user.

Hope this helps you. Thank you.