Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function my_attachment_image($postid=0, $size='thumbnail', $attributes='') {
- $postid = (isset($postid)) ? $postid : get_the_ID();
- $images = get_children(
- array(
- 'post_parent' => $postid,
- 'post_type' => 'attachment',
- 'numberposts' => 1,
- 'post_mime_type' => 'image'
- )
- );
- if (is_array($images)) {
- foreach ($images as $image) {
- $attachment = wp_get_attachment_image_src($image->ID, $size);
- echo "<img src=\"{$attachment[0]}\" {$attributes} />";
- break;
- }
- }
- }
- if ( function_exists('register_sidebar') )
- register_sidebar(array(
- 'before_widget' => '<li id="%1$s" class="widget %2$s">',
- 'after_widget' => '</li>',
- 'before_title' => '<h2>',
- 'after_title' => '</h2>',
- ));
- ?>
Advertisement
Add Comment
Please, Sign In to add comment