Created
May 1, 2020 22:58
-
-
Save joshfeck/69af63d6782b664a86df7baf83db9340 to your computer and use it in GitHub Desktop.
Add "organizer" linked data to event schema markup. Event Espresso 4
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 | |
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file | |
add_action( | |
'AHEE__json_linked_data_for_event__template', | |
'my_organizer_to_linked_data_for_event' | |
); | |
function my_organizer_to_linked_data_for_event() { | |
$o_name = get_post_meta(get_the_ID(), 'organizer_name', true); | |
$o_url = get_post_meta(get_the_ID(), 'organizer_url', true); | |
$organizer = '{ | |
"@type": "Person"'; | |
if (! empty($o_name)) { | |
$organizer .= ',"name": "' . trim($o_name) . '"'; | |
} | |
if (! empty($o_url)) { | |
$organizer .= ',"url": "' . esc_url($o_url) . '"'; | |
} | |
$organizer .= '}'; | |
?>, | |
"organizer": <?php echo $organizer; ?> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment