Skip to content

Instantly share code, notes, and snippets.

@raftaar1191
Last active March 8, 2017 20:12
Show Gist options
  • Save raftaar1191/9c11b1af4308af0b6505b3ce8087ab56 to your computer and use it in GitHub Desktop.
Save raftaar1191/9c11b1af4308af0b6505b3ce8087ab56 to your computer and use it in GitHub Desktop.
Show media count in rtMedia gallery shortcode
<?php
// Check if function doest not exists.
if ( ! function_exists( 'rtmedia_gallery_after_title_add_media_count' ) ) {
function rtmedia_gallery_after_title_add_media_count() {
global $rtmedia_query;
// Check for gallery shortcode
if ( isset( $rtmedia_query->is_gallery_shortcode ) && true === $rtmedia_query->is_gallery_shortcode ) {
// Defalut value for media count.
$media_count = 0;
if ( isset( $rtmedia_query->is_gallery_shortcode ) ) {
// get value from the pagination
$media_count = intval( $rtmedia_query->media_count );
}
?>
<h2 class="rtm-gallery-count">
<?php
echo sprintf( esc_html__( '( %d )', 'buddypress-media' ), intval( $media_count ) );
?>
</h2>
<style type="text/css">
.rtmedia_gallery_wrapper #rtm-gallery-title-container .rtm-gallery-title{
display: inline;
}
.rtmedia_gallery_wrapper #rtm-gallery-title-container .rtm-gallery-count{
display: inline;
margin: 0px;
}
</style>
<?php
}
}
}
add_action( 'rtmedia_gallery_after_title', 'rtmedia_gallery_after_title_add_media_count', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment