Skip to content

Instantly share code, notes, and snippets.

@raftaar1191
Last active March 22, 2017 07:20
Show Gist options
  • Save raftaar1191/ee375c688a542698d48285006b85d5e2 to your computer and use it in GitHub Desktop.
Save raftaar1191/ee375c688a542698d48285006b85d5e2 to your computer and use it in GitHub Desktop.
Add a link below every media in media gallery
<?php
/**
* Add a link below every media in media gallery.
*/
function tmp_rtmedia_rtmedia_after_item_callback() {
global $rtmedia_media;
// Check if $rtmedia_media->id rtMedia id is set and also check for if $rtmedia_media->media_id post id is set
if ( isset( $rtmedia_media->id ) && isset( $rtmedia_media->media_id ) ) {
// rtMedia id.
$media_id = $rtmedia_media->id;
// Post id.
$post_id = $rtmedia_media->media_id;
?>
<a href="http://demo.rtmedia.io/" class="no-popup media-id-<?php echo intval( $media_id ); ?> post-id-<?php echo intval( $post_id ); ?>">Buy Now</a>
<?php
}
}
add_action( 'rtmedia_after_item', 'tmp_rtmedia_rtmedia_after_item_callback', 99 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment