Created
July 24, 2012 15:57
-
-
Save wpscholar/3170845 to your computer and use it in GitHub Desktop.
Function to set the featured image for a given post in WordPress
This file contains hidden or 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
<?php | |
/** | |
* Function to set the featured image for a given post in WordPress | |
* | |
* @author Micah Wood <[email protected]> | |
* @param int $post_id The ID of the post for which we are setting the featured image | |
* @param int $attachment_id The ID of the attachment we want to use as the featured image | |
*/ | |
function set_featured_image( $post_id, $attachment_id ){ | |
update_post_meta( $post_id, '_thumbnail_id', $attachment_id ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment