Skip to content

Instantly share code, notes, and snippets.

@pranali333
Last active February 21, 2017 09:17
Show Gist options
  • Save pranali333/219a3f8ac21a15cd018648997a5f2c14 to your computer and use it in GitHub Desktop.
Save pranali333/219a3f8ac21a15cd018648997a5f2c14 to your computer and use it in GitHub Desktop.
Customize album gallery template to display album description
<?php
// Fetch album description
function custom_rtmedia_get_album_desc(){
global $rtmedia_backbone;
if ( $rtmedia_backbone[ 'backbone' ] ){
echo '<%= album_desc %>';
} else {
return rtmedia_get_album_desc_custom();
}
}
// Filter to display album description in album gallery
function rtm_filter_display_album_desc(){
?>
<div>
<h4><?php echo custom_rtmedia_get_album_desc(); ?></h4>
</div>
<?php
}
add_action( 'rtmedia_after_album_gallery_item', 'rtm_filter_display_album_desc' );
// rtMedia uses Backbone to handle load more / pagination. You also need to filter the JSON response which is handled by Backbone.
function rtmedia_backbone_template_filter_album_desc( $media ){
if( $media->media_type == 'album' ){
$albumdesc = get_post( rtmedia_media_id() );
if( isset($albumdesc) ){
$media->album_desc = $albumdesc->post_content;
}
}
return $media;
}
add_filter( 'rtmedia_media_array_backbone', 'rtmedia_backbone_template_filter_album_desc' );
// Custom function to view album description
function rtmedia_get_album_desc_custom(){
$album_desc = get_post( rtmedia_media_id() );
if( isset($album_desc) ){
$desc = $album_desc->post_content;
}else{
$desc='';
}
return $desc;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment