-
-
Save BeardedGinger/7b6274c6b0859b0bd37ecb646c7eb7b4 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
<?php | |
add_shortcode( 'countdown_by_category', 'countdown_by_category_build' ); | |
/** | |
* A wrapper shortcode for the [tribe_event_countdown] shorcode to allow | |
* displaying countdown by event category | |
*/ | |
function countdown_by_category_build( $atts, $content = null ) { | |
extract( shortcode_atts( array( | |
'category' => '' | |
), $atts, 'countdown_by_category' ) ); | |
ob_start(); | |
$args = array( | |
'post_type' => 'tribe_events', | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'tribe_events_cat', | |
'field' => 'slug', | |
'terms' => $category | |
) | |
), | |
'posts_per_page' => 1 | |
); | |
$event = get_posts( $args ); | |
echo do_shortcode('[tribe_event_countdown id='. $event->ID .']'); | |
$countdown = ob_get_clean(); | |
return $countdown; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment