Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

m.lavarde on "if in the attribut of a shortcode"

$
0
0

Hi all,

I'm trying to customize shortcode Event List Shortcode provided in the plugin Event Organizer in order to have in my sidebar a list of event from a specified category, which is the category of the main page.

So far I wrote the following

<?php
global $wp_query;
$page_id = $wp_query->post->ID;
$category = get_post_meta( $page_id, 'category', true );
?>

<?php
echo do_shortcode('[eo_events event_category="' . $category . '" showpastevents=false]
<div style="background-color: #ececec; width: 160px; padding: 10px; margin: 15px; opacity: 0.91; font-size: 14px; line-height: 20px;">
    <div class="eo-date-container">
		<span class="eo-date-month" style="background-color: #1e8cbe; float: right; text-align: center; width: 50px; line-height: 1.3; margin: 0px; display: block; font-size: 14px; font-variant: small-caps; color: white; letter-spacing: 3.2px;">%start{M}%</span><br/>
		<span class="eo-date-day" style="background: #27b6f7; float: right; text-align: center; width: 50px; line-height: 1.3; margin: 0px; display: block; font-size: 32px;">%start{j}%</span>
	</div>
<div class="eo-event-meta-container">
		<span class="eo-event-title" style="color: #f99734; font-size: 20px; line-height: 30px; font-weight: bold;"><a href="%event_url%">%event_title%</a></span><br/>
		<span class="eo-event-meta" style="font-size: 12px;"> @ <em><a href="%event_venue_url%">%event_venue%</a></em> </span><br/>
			<span class="eo-event-meta" style="font-size: 12px;">de %start{H}%h%start{i}% à %end{H}%h%end{i}% </span>
</div>
<div style="clear:both"></div>

	<div style="align: center;">
		%event_thumbnail%
	</div>
		%event_content%
<div style="font-size: 10px; width: 150px; line-height: 12px; background-color: #F5DA81; margin: 3px; padding: 3px;">
Organisateur et contact : %event_custom_field{organisateur_contact}%
</div>
</div>
[/eo_events]'); ?>

I would like to add some conditions in case %event_content% or %event_venue% or %event_custom_field{organisateur_contact}% are empty.

I tried `if(%event_custom_field{organisateur_contact}%) {
Organisateur et contact : %event_custom_field{organisateur_contact}%
}but it did not work it returns a text if( value of%event_custom_field{organisateur_contact}%`) {
Organisateur et contact : value of %event_custom_field{organisateur_contact}%
}

Thanks in advance for your help


Viewing all articles
Browse latest Browse all 8245

Trending Articles