Last active
March 8, 2017 20:12
-
-
Save raftaar1191/9c11b1af4308af0b6505b3ce8087ab56 to your computer and use it in GitHub Desktop.
Show media count in rtMedia gallery shortcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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