Skip to content

Instantly share code, notes, and snippets.

@kadimi
Last active January 29, 2020 21:04
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 kadimi/f6e6083cc5b8838ff0d8fc68c0fda459 to your computer and use it in GitHub Desktop.
Save kadimi/f6e6083cc5b8838ff0d8fc68c0fda459 to your computer and use it in GitHub Desktop.
Force showing venue without events
<?php
/**
* Force showing venue without events.
*/
add_action( 'loop_no_results', function( $q ) {
/**
* Only once.
*/
static $once = 0;
if ( $once++ ) {
return $q;
}
/**
* Only main query.
*/
if ( ! $q->is_main_query() ) {
return $q;
}
/**
* Only on venue taxonomy.
*/
if ( ! ( $q->query[ 'sp_venue' ] ?? true ) ) {
return $q;
}
/**
* Show title, description and map.
*/
$venue_taxonomy_id = get_queried_object()->term_id;
?>
<article id="venue-<?php the_ID(); ?>" class="venue-archive">
<header class="venue-header"><h1 class="venue-title"><?php echo single_term_title(); ?></h1></header>
<div class="venue-description"><?php echo do_shortcode( term_description( $venue_taxonomy_id ) ); ?></div>
<div class="venue-map"><?php echo sp_get_template( 'venue-map.php', array( 'meta' => get_option( 'taxonomy_' . $venue_taxonomy_id ) ) ); ?></div>
</article>
<?php
return $q;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment