Created
November 16, 2018 15:47
-
-
Save barryhughes/e758b129f98dca7b9723d577169bcd14 to your computer and use it in GitHub Desktop.
Adds a list of clickable category links below the main event search bar (sometimes referred to as the "Tribe Bar"). Tested with TEC 4.6.26.
This file contains hidden or 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 a list of clickable category links below the event | |
| * search bar. | |
| * | |
| * Can be easily styled using the following selector: | |
| * | |
| * .the-events-calendar-category-list | |
| */ | |
| add_action( 'tribe_events_bar_after_template', function() { | |
| $terms = get_terms( [ | |
| 'taxonomy' => Tribe__Events__Main::TAXONOMY | |
| ] ); | |
| if ( empty( $terms ) || is_wp_error( $terms ) ) { | |
| return; | |
| } | |
| print "<div class='the-events-calendar-category-list'> <ol>"; | |
| foreach ( $terms as $single_term ) { | |
| $url = esc_url( get_term_link( $single_term ) ); | |
| $name = esc_html( get_term_field( 'name', $single_term ) ); | |
| print "<li> <a href='$url'>$name</a> </li>"; | |
| } | |
| print "</ol> </div>"; | |
| } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment