You can’t directly use PHP in the templates. However, interestingly, you can create your own placeholders. Let’s say you want to create a placeholder called #_EVENTURL and the value was stored as an ACF called ‘eventurl’. Then you would add the following code snippet to create the #_EVENTURL placeholder:
add_filter('em_event_output_placeholder','my_em_output_placeholders',1,3);
function my_em_output_placeholders($replace, $EM_Event, $result){
if( preg_match( '/#_EVENTURL.*/', $result ) ) {
$url = get_field('eventurl', $EM_Event->post_id);
if ( empty( $url ) ) {
$replace = $url;
}
}
return $replace;
}
You could then add #_EVENTURL to the template.
You could use the Code Snippets plugin to add the code snippet.
You can handle create multiple placeholders in the code snippet. For example:
add_filter('em_event_output_placeholder','my_em_output_placeholders',1,3);
function my_em_output_placeholders($replace, $EM_Event, $result){
if( preg_match( '/#_FIELD1.*/', $result ) ) {
$url = get_field('field1', $EM_Event->post_id);
if ( empty( $url ) ) {
$replace = $url;
}
}
else if( preg_match( '/#_FIELD2.*/', $result ) ) {
$url = get_field('field2', $EM_Event->post_id);
if ( empty( $url ) ) {
$replace = $url;
}
}
return $replace;
}
Here’s the documentation on the em_event_output_placeholder filter: https://wp-events-plugin.com/tutorials/create-a-custom-placeholder-for-event-formatting/
-
This reply was modified 1 year, 4 months ago by joneiseman.