I found the following code online and customized it to pull the xml feeds from our online calendar software and display event information on several different WP pages.
function otpl_add_class_feed() {
if ( is_page(48) ) {
$url = "http://orion.lib.mi.us/evanced/lib/eventsxml.asp?ag=&et=Computer+Class&nd=31&dm=exml&alltime=1";
$xml = simplexml_load_file($url);
foreach($xml->item as$item)
{
echo "<div id='computer-classes'>";
echo "<p class='event-title'><a href='".$item->link."'>".$item->title."</a></p>";
echo "<p class='event-date'>".$item->date." from ".$item->time." to ".$item->endtime."</p>";
echo "<p class='event-desc'>".$item->description."</p>";
echo "<p class='event-signup'><a href='".$item->link."'>Register Online</a>.</p>";
echo "</div>";
}
} // END IF
}
How can I include a conditional statement so that if $item->date. is populated the above code will run but if $item->date. is empty then another code stating that there are no events scheduled will run? I'm sure it's something simple but my understanding of syntax isn't very strong. My few attempts have broken my functions page.
if( isset($item->date) && strlen($item->date)>0 ){...}