Guest
Public paste!

gcox

By: a guest | Jan 28th, 2010 | Syntax: PHP | Size: 0.79 KB | Hits: 46 | Expires: Never
This paste has a previous version, view the difference. Copy text to clipboard
  1. /*
  2. I'm trying to add a function to my theme's functions.php that queries a table created by Kieran O'Shea's calendar module. Though I do have entries in the "wp_calendar" table, the queries don't display any results.
  3.  
  4. The $myTest section was added just to test if anything could be queried at all. This also returns nothing.
  5. */
  6.  
  7. function upcomingEvents() {
  8.   global $wpdb;
  9.   $myTest = $wpdb->get_results("select count(*) as count from $wpdb->calendar");
  10.   echo "<h2 id=\"mytest\">count=" . $myTest->count . "</h2>";
  11.  
  12.   $myList = $wpdb->get_results("SELECT * FROM $wpdb->calendar ORDER BY event_begin DESC");
  13.   foreach ($myList as $myItem) {
  14.         echo "begin:" . $myItem->event_begin . "--title:" . $myItem->event_title;
  15.   }
  16.  
  17. //Corresponding shortcode
  18. add_shortcode('upcoming','upcomingEvents');
  19. }