Skip to content

Instantly share code, notes, and snippets.

@BeardedGinger
Last active May 3, 2016 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BeardedGinger/7b6274c6b0859b0bd37ecb646c7eb7b4 to your computer and use it in GitHub Desktop.
Save BeardedGinger/7b6274c6b0859b0bd37ecb646c7eb7b4 to your computer and use it in GitHub Desktop.
<?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