• I’m trying to get two divs to sit next to each other. This works when there’s no PHP or wordpress hooks, but it won’t work when trying to hook it into wordpress.

    Here’s my index:

    <?php if (has_post_format('status')) : ?>
    
                            <div class = "twocolumnpost">
                                <div <?php post_class() ?>>
                                    <?php if (has_post_thumbnail()) : ?>
                                        <div class = "post-thumb">
                                            <a href="<?php echo the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
                                        </div>
                                    <?php endif; ?>
                                </div>
                            </div>
    
                        <?php else : ?>
    
                            <div class = "singlecolumnpost">
                                <div <?php post_class() ?>>
                                    <?php if (has_post_thumbnail()) : ?>
                                        <div class = "post-thumb">
                                            <a href="<?php echo the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
                                        </div>
                                    <?php endif; ?>
                                </div>
                            </div>
    
                        <?php endif; ?>

    And my CSS:

    .singlecolumnpost .post {
        float: left;
        display: block;
    }
    
    .twocolumnpost .post {
        float: left;
        display: block;
        width: 50%;
    }
    
    .singlecolumnpost img {
        display: block;
        max-width: 940px;
        max-height: 529px;
        width: 100%;
        padding: 5px 0;
    }
    
    .twocolumnpost img {
        max-width: 460px;
        max-height: 259px;
        width: 100%;
        padding: 5px 0 5px 0;
    }

    Any help would be really appreciated.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    You’ll need to link us the Webpage with the issue

    Thread Starter Adam

    (@addrum)

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Do you mind if I label this post as NSFW (not safe for work)? I can’t really handle that picture of David in his underwear at work

    Thread Starter Adam

    (@addrum)

    Aha! No worries. I’ll switch it out just in case.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    To clarify, which two divs on that page do you want side by side?

    Thread Starter Adam

    (@addrum)

    Sorry, the twocolumnpost ones – i.e. the middle 2 posts of a video and a half width image.

    Thread Starter Adam

    (@addrum)

    I’ve realised it works in my standard HTML page because I have declared two post classes within twocolumnpost whereas with wordpress I have only done one. If I add a second post class within twocolumnpost to my index.php it duplicates the image. I don’t want that. The should sit side by side no problem. Is there a way I can have two posts within a div and have the second one show the next post?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[NSFW] Two div's wont sit next to each other – they do without PHP’ is closed to new replies.