Last active
March 2, 2017 09:01
-
-
Save cdillon/3fe1a907cdc9a7d7e010 to your computer and use it in GitHub Desktop.
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
/** | |
* A shortcode to display the number of testimonials. | |
* | |
* For Strong Testimonials plugin. | |
* | |
* For all: [my_testimonial_count] | |
* For a specific category (by slug): [my_testimonial_count category="abc"] | |
* | |
* @param $atts | |
* @param null $content | |
* | |
* @return int | |
*/ | |
function my_testimonial_count( $atts, $content = null ) { | |
$atts = shortcode_atts( | |
array( | |
'category' => '', | |
), | |
$atts | |
); | |
$args = array( | |
'posts_per_page' => -1, | |
'post_type' => 'wpm-testimonial', | |
'post_status' => 'publish', | |
'wpm-testimonial-category' => $atts['category'], | |
'suppress_filters' => true, | |
); | |
$posts_array = get_posts( $args ); | |
return count( $posts_array ); | |
} | |
add_shortcode( 'my_testimonial_count', 'my_testimonial_count' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment