WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to be able to seperate the first image form the post into a <div> tag and link it to the post page and be able to add html around the post text elements seprately.

Any help is greatly appreciated

This is what I have tried

                while (have_posts()) : the_post();
                echo "<li class='homePost'>\n";
                    echo the_content();
                    echo '<a href="' . get_permalink() . '">';
                    echo '</a>'; 

                echo "</li>\n";
share|improve this question
I guess this is what the featured image is meant to replace... – kalpaitch Oct 22 '12 at 12:54
up vote 2 down vote accepted

Look at this snippet from CSS-Tricks. It gets the first image from a post.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.