Skip to content

Instantly share code, notes, and snippets.

@sidharrell
Created February 28, 2014 21:38
Show Gist options
  • Save sidharrell/9280456 to your computer and use it in GitHub Desktop.
Save sidharrell/9280456 to your computer and use it in GitHub Desktop.
add featured image support to event posts
// in includes/event-management/insert_event.php, put this in after
// $post_id = wp_insert_post($my_post);
// which is line 508 in 3.1.36.4.P
$event_thumbnail_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM $wpdb->posts WHERE guid = '%s'", $event_thumbnail_url));
if (!empty($event_thumbnail_id)) {
$wpdb->update( $wpdb->posts, array('post_parent' => $post_id), array('id' => $event_thumbnail_id));
add_post_meta($post_id, '_thumbnail_id', $event_thumbnail_id);
}
// and in includes/event-management/update_event.php, put this in after
// $post_id = wp_update_post($my_post);
// which is line 609 in 3.1.36.4.P
$event_thumbnail_id = $wpdb->get_var($wpdb->prepare("SELECT id FROM $wpdb->posts WHERE guid = '%s'", $event_thumbnail_url));
if (!empty($event_thumbnail_id)) {
$wpdb->update( $wpdb->posts, array('post_parent' => $post_id), array('id' => $event_thumbnail_id));
update_post_meta($post_id, '_thumbnail_id', $event_thumbnail_id);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment