Skip to content

Instantly share code, notes, and snippets.

@rahul3883
Last active April 17, 2017 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rahul3883/e4f5e332478fb2d880142dfa7e968b20 to your computer and use it in GitHub Desktop.
Save rahul3883/e4f5e332478fb2d880142dfa7e968b20 to your computer and use it in GitHub Desktop.
Display album link on rtMedia's single media page
<?php
/**
* Display album name with permalink.
*
* @param $media_id Current media id for which we need to display the album link.
*/
function tmp_rtm_display_album_link( $media_id ) {
global $rt_ajax_request;
// Show only on full media page, not on media popup.
if ( empty( $rt_ajax_request ) && ! empty( $media_id ) ) {
global $rtmedia_media;
if ( $media_id === $rtmedia_media->id ) {
$rtm_album_name = rtmedia_album_name();
if ( ! empty( $rtm_album_name ) ) {
?>
<div id="tmp-rtm-media-album-link" class="tmp-rtm-media-album-link">
<span><?php esc_html_e( 'Album', 'rtmedia' ) ?>: </span>
<a href="<?php rtmedia_album_permalink(); ?>"><?php echo $rtm_album_name; ?></a>
</div>
<?php
}
}
}
}
add_action( 'rtmedia_actions_before_description', 'tmp_rtm_display_album_link', 8 );
@rahul3883
Copy link
Author

rahul3883 commented Apr 17, 2017

Place this code snippet in your theme's functions.php file.

Note: This code snippet will show album link only on single media page, not on media popup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment