• ReinoutSch

    (@reinoutsch)


    This might be a stupid question but I just can’t figure it out. I want to add some PHP to a DIV inside my custom theme. Everytime I add the code inside a DIV it jumps out.

    Link to page:
    http://reinowo58.fiftyeight.axc.nl/hoe/

    As you can see on the right side there are 2 divs. I added a piece of PHP to the container that grabs the latest post. But it appears outside the DIV.

    This is the code:

    <div style="width: 250px; height: 325px; background-color: #ebecec; border-radius: 25px; padding: 25px;">
    <div style="width: 170px; height: 40px; background-color: #fb3099; border-radius: 18px; margin-left: auto; margin-right: auto; text-align: center;">
    <h2 style="padding-top: 14px;">NIEUWS</h2>
    </div>
    [insert_php] query_posts('showposts=1'); [/insert_php]
    [insert_php] while (have_posts()) : the_post(); [/insert_php]
    [insert_php] endwhile;[/insert_php]
    
    </div>

    As you can see on the page the text is on the bottom of the page instead of inside the DIV. Please help me out with this one.

    https://ww.wp.xz.cn/plugins/insert-php/

Viewing 1 replies (of 1 total)
  • WillBontrager

    (@willbontrager)

    Hi,

    Two things.

    1.
    For a theme template, use regular PHP with its start-end tags <?php and ?> instead of Insert PHP with its [insert_php] and [/insert_php] tags. Use Insert PHP only for posts and pages.

    2.
    For future reference, if you do decide to use Insert PHP within your posts and pages, read the
    http://www.willmaster.com/software/WPplugins/insert-php-wordpress-plugin-instructions.php
    page for special things to look out for. As an example, the way you have it in your theme template wouldn’t work in a post or page because all the code would need to be within one set of [insert_php] … [/insert_php] tags, not broken up into three sets.

    Have a wonderful June!

    Will

Viewing 1 replies (of 1 total)

The topic ‘Adding PHP to a DIV’ is closed to new replies.