Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $attachments = get_children(array
- ('post_parent' => get_the_ID(),
- 'post_type' => 'attachment',
- 'post_mime_type' => 'image',
- 'orderby' => 'menu_order'));
- if ( has_post_thumbnail() ) {
- the_post_thumbnail( array(150,150) );
- } elseif ($attachments) {
- if ( ! is_array($attachments) ) continue;
- $count = count($attachments);
- $first_attachment = array_shift($attachments);
- echo wp_get_attachment_image($first_attachment->ID);
- } else {
- echo '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/default.jpg" />';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment