I've added my own function to save_post as follows:
add_action( 'save_post', 'save_recipe' );
function save_recipe( $post_id ) {
// ... set $thumb_id from custom code ...
set_post_thumbnail($post_id, $thumb_id);
}
Now if I check my DB, nothing is set for the field _thumbnail_id
inside the wp_postmeta
table.
The Strange thing is if I use a die()
function right after set_post_thumbnail, and check the DB my line was entered into the DB, so it is like some built in code from wordpress (or my theme) that is stripping it out after the fact.
Any ideas? I assume it has something to do with the featured image code that gets added when you use add_theme_support( 'post-thumbnails' );
in your functions.php
.
I should note I'm using Wordpress 3.4.1 as a Network, in addition to using the Thesis 1.8.5 theme which may be adding some complexity.
Also I know I could be using the built in featured post section, but I'm coding this so that I can use identical functions from the front end to add new posts (with a set featured image that the user uploads).
Thanks!