WordPress.org

Forums

Separating images and text in a single post (7 posts)

  1. Lars M
    Member
    Posted 6 years ago #

    Problem:
    Inside single.php;
    I want my images displayed in another div than the the rest of my content (rest of content, the text). I've read about the strip tag function, but couldn't get it to work.

    A simple example
    <div id="images">images</div>
    <div id="text">text</div>

  2. Hiranthi
    Member
    Posted 6 years ago #

    Wouldn't it be easier to use something like NextGen?

  3. Lars M
    Member
    Posted 6 years ago #

    Thanks, but I don't really like NextGen — and I'm trying to avoid using any plugins for this. It should be really simple, but obviously I don't know enough PHP to get the get_content to display images in one div and text in another. I hope someone will be able to help out?

  4. Lars M
    Member
    Posted 6 years ago #

    OK, so this gets only the images:

    $images =& get_children( 'post_type=attachment&post_mime... . $post->ID );
    foreach( $images as $imageID => $imagePost )
    echo wp_get_attachment_image($imageID... 'thumbnail', false);
    How do I get the rest of the content into the other div, with images being the only exception?

  5. Lars M
    Member
    Posted 6 years ago #

    This code removes images from a post
    http://chrisschuld.com/2008/08/removing-images-from-a-wordpress-post/

    but doesn't link to the attachments page or show alt info, how do I include all that?

  6. Hiranthi
    Member
    Posted 6 years ago #

    What about combining your last two posts?

  7. Lars M
    Member
    Posted 6 years ago #

    Yes, I did.. the only problem I have is that the image column doesn't link to the attachmentspage, unless I use `echo wp_get_attachment_link' but then the thumbnails code stops working. I've sort of hacked it through css, but I'm still sure that there is an easier way to hack this (without using plugins).

Topic Closed

This topic has been closed to new replies.

About this Topic