Created
February 28, 2014 21:38
-
-
Save sidharrell/9280456 to your computer and use it in GitHub Desktop.
add featured image support to event posts
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
// 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