Title: WordPress loop that only pulls the image?
Last modified: August 20, 2016

---

# WordPress loop that only pulls the image?

 *  [lenglain](https://wordpress.org/support/users/lenglain/)
 * (@lenglain)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/wordpress-loop-that-only-pulls-the-image/)
 * For a special project I need to have a bunch of divs show different parts of 
   the same post. I’ve been successful but now I need One div to show JUST the image,
   and the other JUST the text.
 * Is this possible?

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [lenglain](https://wordpress.org/support/users/lenglain/)
 * (@lenglain)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/wordpress-loop-that-only-pulls-the-image/#post-2180796)
 * UPDATE:
 * After tinkering I realized there was an easy way to do this.
 * if the post text and image shows up in a div class such as “.entry” then you 
   can do this in css:
 * .entry img {
    display:none; }
 * Boom that takes care of the div that should only show text.
 * to hide the text is slightly trickier, because both text and images are wrapped
   up in <p> tags so
 * .entry p {
    display:none; }
 * would hide the entire post text and images alike.
 * My fix is to start any blog post i write with <span> and close the tag at the
   end of my post. then I can do this in the stylesheet:
 * .entry span {
    display:none; }
 * although complaining about writing <span> before any blog post is a little ridiculous(
   takes half a second) if there was a way to automatically have wordpress wrap 
   text in <span> tags that would be sweet.
 * any comments suggestions would be greatly appreciated.
 *  [vlad.ionescu](https://wordpress.org/support/users/vladionescu/)
 * (@vladionescu)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/wordpress-loop-that-only-pulls-the-image/#post-2180800)
 * well first off I think this is in the wrong forum, but anyway, onto something
   a bit more helpful 🙂
 * without resorting to painful hacks like the <span> wrap I suggest you use php
   to find any <img> tags and yank those from the post body. then display the images
   in one div and the post with all img tags removed in another
 * php is your best bet here imho
 *  [vlad.ionescu](https://wordpress.org/support/users/vladionescu/)
 * (@vladionescu)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/wordpress-loop-that-only-pulls-the-image/#post-2180803)
 * ps. here is a nice example of a loop using regex to pull the first image out 
   of the post content. came upon it and thought it was relevant to your project.
 * [http://coding.smashingmagazine.com/2009/06/10/10-useful-wordpress-loop-hacks/](http://coding.smashingmagazine.com/2009/06/10/10-useful-wordpress-loop-hacks/)
 * scroll down to #10 on that list
 *  Thread Starter [lenglain](https://wordpress.org/support/users/lenglain/)
 * (@lenglain)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/wordpress-loop-that-only-pulls-the-image/#post-2180804)
 * I have no idea how I would use php to do that (that was kind of my original question)
   so unless somebody might show me the light css it is for now.
 *  Thread Starter [lenglain](https://wordpress.org/support/users/lenglain/)
 * (@lenglain)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/wordpress-loop-that-only-pulls-the-image/#post-2180805)
 * ahh didnt see that second post I’ll check the link out thanks

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘WordPress loop that only pulls the image?’ is closed to new replies.

## Tags

 * [custom](https://wordpress.org/support/topic-tag/custom/)
 * [images](https://wordpress.org/support/topic-tag/images/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)

 * 5 replies
 * 2 participants
 * Last reply from: [lenglain](https://wordpress.org/support/users/lenglain/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/wordpress-loop-that-only-pulls-the-image/#post-2180805)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
