large shade tree

Navigation

Information

Recent Posts

Shade Tree Sites |Building Better Websites

How to Assign a Default Post Thumbnail

To assign a default thumbnail image in WordPress change the highlighted link below to the location of the image you would like to use for your default image and then paste the code below in your functions.php file:

add_action( ‘save_post’, ‘wptuts_save_thumbnail’ );
function wptuts_save_thumbnail( $post_id ) {
// Get Thumbnail $post_thumbnail = get_post_meta( $post_id, $key = ‘_thumbnail_id’, $single = true );
// Verify that post is not a revision if ( !wp_is_post_revision( $post_id ) ) { // Check if Thumbnail exists if ( empty( $post_thumbnail ) ) { // Add thumbnail to post update_post_meta( $post_id, $meta_key = ‘_thumbnail_id’, $meta_value = ‘http://yoursite.com/your_image_url.jpg’ ); } }
}

Source:  WPRecipes