Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Adds a custom Events Manager placeholder to display the WordPress category.
- *
- * @param string $replacement The string to be shown in the front end.
- * @param object $EM_Event The current Events Manager Event object.
- * @param string $placeholder The current placeholder (#_PLACEHOLDER).
- * @return string
- */
- function stonehenge_em_placeholder_wp_category( $replacement, $EM_Event, $placeholder ) {
- if( '#_WPCATEGORY' === $placeholder ) {
- $categories = get_the_category( $EM_Event->post_id );
- foreach( $categories as $category ) {
- $replacement = $category->name;
- }
- }
- return $replacement;
- }
- add_filter( 'em_event_output_placeholder', 'stonehenge_em_placeholder_wp_category', 10, 3 );
Advertisement
Add Comment
Please, Sign In to add comment