Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 15th, 2012  |  syntax: None  |  size: 0.84 KB  |  hits: 6  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Add image as attachment link in Post topic
  2. $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'your-image-size' )
  3.        
  4. echo $image[0] ;is your link
  5.        
  6. <?php if (has_post_thumbnail( $post->ID ) ): ?>
  7. <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); ?>
  8. <a href='<?php echo $image[0]; ?>'> my image link </a>
  9.        
  10. // Get URL of first image in a post
  11.  
  12. function postimage( $echo = true ) {
  13.     $image = get_children( array(
  14.         'post_parent' => get_the_ID(),
  15.         'post_type' => 'attachment',
  16.         'numberposts' => 1,
  17.         'order' => 'asc',
  18.         'orderby' => 'ID',
  19.         'post_mime_type' => 'image',
  20.     ) );
  21.     $image_url = ( $image ) ? wp_get_attachment_url( current($image)->ID ) : "No Image";
  22.     if( $echo )
  23.         echo $image_url;
  24.     else
  25.         return $image_url;
  26. }