Created
August 27, 2013 23:18
-
-
Save sidharrell/6360284 to your computer and use it in GitHub Desktop.
shortcode for displaying a list of upcoming event titles only
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function show_event_titles($atts) { | |
ob_start(); | |
global $wpdb; | |
$sql = "SELECT e.* FROM ". EVENTS_DETAIL_TABLE . " e "; | |
$sql .= " WHERE is_active = 'Y' ";//Makes sure event is active | |
$sql .= " AND event_status != 'D' ";//Makes sure event is not deleted | |
//$sql .= " AND event_status = 'O' ";//Un-comment to only show ongoing events | |
//Removing this line keeps events from showing that may be expired | |
$sql .= " AND start_date >= '".date ( 'Y-m-d' )."' "; | |
//These lines are used to show events within a registration start and end period | |
$sql .= " AND e.registration_start <= '".date ( 'Y-m-d' )."' "; | |
$sql .= " AND e.registration_end >= '".date ( 'Y-m-d' )."' "; | |
//This line orders the events by date | |
$sql .= " ORDER BY date(start_date), id"; | |
$results = $wpdb->get_results($sql); | |
if ($wpdb->num_rows > 0) { | |
foreach ($results as $result){ | |
$event_name=stripslashes($result->event_name); | |
echo $event_name . '<br>'; | |
} | |
} | |
$buffer = ob_get_contents(); | |
ob_end_clean(); | |
return $buffer; | |
} | |
add_shortcode('EVENT_TITLES', 'show_event_titles'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment