Created
December 13, 2012 01:39
-
-
Save davemac/4273322 to your computer and use it in GitHub Desktop.
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
| // http://wordpress.stackexchange.com/a/75512/131 | |
| if (has_post_thumbnail()) | |
| //if the post already has a post thumbnail then just use that | |
| the_post_thumbnail($size = 'post-thumbnail', $attr = ''); | |
| else{ | |
| //if not then convert the custom field to the post thumbnail and display that | |
| $at_url = get_post_meta($post->ID, 'image', true); | |
| $at_id = get_image_id_by_url($at_url); | |
| delete_post_meta($post->ID, 'image'); | |
| if ($at_id){ | |
| set_post_thumbnail($post, $at_id); | |
| the_post_thumbnail($size = 'post-thumbnail', $attr = ''); | |
| }else{ | |
| //else just display a default image or not :) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment