Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Floats Automatic in Single Post Template WordPress

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #37073
    MerlinESQ
    Member

    I would like to float two images in the WordPress single post template. One to be in the top right hand corner and the other in a specific spot on the left side toward the middle of the post. I’m sorry I’m having trouble explaining it, but I will try my best.

    Using the diagram below, img is the image on the top right with text wrapping around it. Then the second image img2 will also have the text wrapped around it. What I’m trying to do is make a template that will have the images in set places on the page and text from WordPress will be inserted around them when a person makes a post. Provided that the author puts enough words in the blog, it will wrap around the img2 and I don’t want to have to manually add the img2 each time.


    img-



    -img2





    img2 will appear say 500px from the top of the start of the content with text wrapping. I hope this makes sense. I can explain more if you want to try and help.

    #98648
    TheDoc
    Moderator

    If you want text to flow around the images, they’ll have to be a part of the post and floated. You’ll end up with some pretty crazy positioning if you try to do it any other way.

    Why not just get the user to put the images into the post and then use CSS and nth-child to style each image accordingly? Or, for further browser support, you could use jQuery.

    #98660
    Krist
    Member

    Basic code [PHP]


    // Looping
    $i = 1;
    foreach($posts as $post){
    $align = $post % 2 == 0 ? 'left' : 'right';
    echo '';
    echo '

    Cotent here

    ';
    $i++;
    }

    #97611
    MerlinESQ
    Member

    Thanks for the feedback Krist.

    “Why not just get the user to put the images into the post and then use CSS and nth-child to style each image accordingly?”

    Do you want an answer or was this rhetorical? :)

    #76562
    Krist
    Member

    Simple logic and I tend to prefer server-side logic.

    Wine is used not only meals but also in salads and desserts

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘CSS’ is closed to new topics and replies.