Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Function to get wordpress image attachment
- function fetchthumb() {
- global $post;
- $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID );
- $attachments = get_posts($args);
- if ($attachments) :
- foreach ( $attachments as $attachment ) {
- if( wp_attachment_is_image( empty($attachment->ID) ) )
- echo '<img src="'.$scriptpath.'/images/empty.gif" alt="this post has no image" />';
- else echo wp_get_attachment_image( $attachment->ID, 'thumbnail');
- break;
- }
- endif;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement