Posted By

janvdm on 02/15/11


Tagged

image wordpress first


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

janvdm
Jarek
kirichev
hkamci


Wordpress Get The First Image


 / Published in: PHP
 

  1. <?php //GET THE FIRST IMAGE
  2. $args = array(
  3. 'order' => 'ASC',
  4. 'orderby' => 'menu_order',
  5. 'post_type' => 'attachment',
  6. 'post_parent' => $post->ID,
  7. 'post_mime_type' => 'image',
  8. 'post_sta tus' => null,
  9. );
  10. $attachments = get_posts($args);
  11. if ($attachments) {
  12.  
  13. foreach ($attachments as $attachment) {
  14.  
  15. echo wp_get_attachment_url($attachment->ID, 'full', false, false);
  16. }
  17. } ?>');">

Report this snippet  

You need to login to post a comment.