you need to make another version of the snippet and rename the function name attribute
eg.
has_venueurl
$EM_Event->event_attributes['venue_url'])
my_em_has_attribute_event_output_condition
to something like
has_email
$EM_Event->event_attributes['Email'])
my_em_has_attribute_event_output_condition_email
Thanks very much, that’s brilliant!
One last question.
Is it possible to write the conditional so that it includes an ‘and / or’ statement?
This would be useful for headings eg:
{has_facebookurl} and /or {has_twitterurl}
Social Media
{/has_facebookurl} and / or {/has_twitterurl}
Think I’ve got it, nesting seems to work.
As per the instructins at the bottom of the page:
http://wp-events-plugin.com/documentation/conditional-placeholders/
Actually, I can’t get nesting to work for this purpose. It seems all conditionals have to be satisfied or the heading won’t display.
I’m still looking for an ‘or’ function.
did you try to add this line in your wp-config.php?
define('EM_CONDITIONAL_RECURSIONS',2);
Yes, I did, thanks.
I think I got it to work as it should. It’s just that it doesn’t do exactly what I want it to.
(In the case of two nested conditionals) it seems that both conditionals have to be met for the heading to be displayed. If only one is met, then the heading isn’t displayed.
This is my formatting code.
{has_facebookurl}
{has_twitterurl}
<h2><strong><span style="color: #ff6600;">Social Media</span></strong><br/></h2>
{/has_twitterurl}
{/has_facebookurl}
Hiya,
Yes, there’s no way to do an ‘OR’ with the conditional placeholders. What you’d really need to do is add further conditionals like so to ensure your HTML is only added once;
{has_facebookurl}
{not_have_twitterurl}
<h2><strong><span style="color: #ff6600;">Social Media</span></strong><br/></h2>
{/not_have_twitterurl}
{/has_facebookurl}
and
{has_twitterurl}
{not_have_facebookurl}
<h2><strong><span style="color: #ff6600;">Social Media</span></strong><br/></h2>
{/not_have_facebookurl}
{/has_twitterurl}
What would be much more productive though is something like;
{show_socmed}
<h2><strong><span style="color: #ff6600;">Social Media</span></strong><br/></h2>
{/socmed}
and have your custom placeholder function do the necessary conditional legwork instead.
Thanks
Thanks philipjohn,
They are both useful bits of code. I didn’t know about {not_have_…}
Having the ‘custom placeholder function do the necessary conditional legwork’ is certainly best. I’ll see what I can do with the code.
The {not_have_…} conditionals are useable in this example, when you only have a couple of statements you want to check. But I’ve another with 5, and then all the combinations you have to account for become much too many. (Plus all the processing needed for all the nesting.)
…I understand now.
I’d have to create the {not_have_…} conditional myself.