Skip to content

Instantly share code, notes, and snippets.

@bigandy
Created December 15, 2011 14:43
Show Gist options
  • Save bigandy/1481326 to your computer and use it in GitHub Desktop.
Save bigandy/1481326 to your computer and use it in GitHub Desktop.
Not working, giving an error. How to insert variable into object???
function year_sum($year) {
return $minutes_cycled_year = $wpdb->get_var($wpdb->prepare("
SELECT SUM($wpdb->postmeta.meta_value)
FROM $wpdb->postmeta, $wpdb->posts
WHERE $wpdb->postmeta.meta_key='exercise-minutes'
AND $wpdb->postmeta.post_id=$wpdb->posts.id
AND year($wpdb->posts.post_date)='$year'
"));
}
echo year_sum(2011);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment