Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Wordpress "events manager" conditional placeholder code WordPress



I'm using the Wordpress Events Manager plugin on and I want to display a button on each calendar day that has an attribute set, in this instance the attribute is "ticketprice",

Below is some code I got from which is how a user got the attribute to show if it was selected as a dropdown, I'm using a text-field and need this to work if the field is not empty.

<strong>Example code that needs changing:</strong>

// Conditional Placeholder for ticket price
add_action('em_event_output_condition', 'my_em_styles_event_output_condition', 1, 4);
function my_em_styles_event_output_condition($replacement, $condition, $match, $EM_Event){
global $wpdb;
$postid = $wpdb->get_col("SELECT post_id FROM $wpdb->postmeta WHERE $wpdb->postmeta.meta_value = '{$EM_Event->event_id}' AND meta_key='_event_id'", 0 );
$styles_check = $wpdb->get_col("SELECT meta_value FROM $wpdb->postmeta WHERE $wpdb->postmeta.post_id = $postid[0] AND meta_key='styles'", 0 );
if( is_object($EM_Event) && preg_match('/^is_styles_(.+)$/',$condition, $matches) ){
if( in_array($matches[1],$styles_check) ){
$replacement = preg_replace("/\{\/?$condition\}/", '', $match);
$replacement = '';
return $replacement;

Here's some more documentation on the conditional placeholder:

So the end code would be like {has_tickets}Tickets are #_ATT{ticketprice}.{/has_tickets}

Can anyone help?


Answers (0)

No answers yet.