• 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

    (@lenglain)

    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.

    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

    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/

    scroll down to #10 on that list

    Thread Starter lenglain

    (@lenglain)

    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

    (@lenglain)

    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.