Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

WordPress: Wrap img in DIV

  • 11-12-2012 12:51PM
    #1
    Registered Users, Registered Users 2 Posts: 47


    HI,

    I'm working on a WordPress site and want to be able to wrap the images in posts in a div when they are added through upload/insert section when your editing a page.

    i.e when someone uploads an image it is wrapped in a div with a class name separate to the text.

    at the moment my code looks like this

    <div class="container">
    <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
    <div class="eight columns alpha">
    <h3><?php the_title(); ?></h3>
    <?php the_content(); ?>
    </div>
    <div class="eight columns omega">
    <!-- Where I want the image to go -->
    </div>
    <?php endwhile; ?>
    <?php endif; ?>
    </div>

    I get that the <?php the_content(); ?> is calling all content on the page that's why all content is showing in the first div and the second is empty. Is there a way to differentiate between text and images in a post/page?

    Any help on this would be great

    Cheers


Comments

Advertisement