Last active
January 29, 2020 21:04
-
-
Save kadimi/f6e6083cc5b8838ff0d8fc68c0fda459 to your computer and use it in GitHub Desktop.
Force showing venue without events
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 | |
/** | |
* 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