• Resolved timdevogel

    (@timdevogel)


    Hi, I want to ad a banner area after my first expert on my home page (https://www.elektroretailmagazine.nl). I’ve inserted the following code in index.php of my child theme, but it doesn’t work. What am I doing wrong?

    The code:

    <?php if ( ot_get_option(‘blog-standard’) == ‘on’): ?>
    <?php $i = 1; ?> <!– initialize the post counter –>
    <?php while ( have_posts() ): the_post(); ?>
    <?php get_template_part(‘content-standard’); ?>
    <?php if ($i % 1 == 0) { // if we’ve displayed 1 post
    echo ‘<div class=”my-ad-widget”>’; // add a container
    dynamic_sidebar(‘WidgetsNaEerstePost’); // insert the ad sidebar
    echo ‘</div>’; // close container
    }
    $i++; // increment the post counter
    ?>
    <?php endwhile; ?>
    <?php else: ?>

Viewing 9 replies - 16 through 24 (of 24 total)
  • Thread Starter timdevogel

    (@timdevogel)

    Nope, now the whole layout was messed up…

    Remove ob_end_clean(); from the code and also change the ID of the sidebar to lowercase in both register_sidebar() and dynamic_sidebar() functions. Also the class .my-ad-widget should have float: left to display properly.

    Thread Starter timdevogel

    (@timdevogel)

    Sorry, must be my lack of knowledge, but you have me stumped. I can’t find any of those in the index.php you placed on pastebin.

    I removed it just now ?? Just copy paste the entire code and make sure to use only lower cases in register_sidebar() – widgetsnaeerstepost

    Thread Starter timdevogel

    (@timdevogel)

    Right, my index.php now looks like this: https://pastebin.com/puzPp6nV

    and I styled the widget with:
    .my-ad-widget {
    float: left;
    }

    But… nothing shows up!

    That CSS went inside the final media query because it was missing a closing bracket }. Place a bracket above the code:

    }
    
    .my-ad-widget {
        float: left;
    }

    The ad image is too big, so consider resizing it.

    Thread Starter timdevogel

    (@timdevogel)

    Cool Jesin, it works. Thanks for the effort and your patience.
    I’ll fiddle around with it a bit now. It’s for a potential client who probably wants to advertise in that position. So now I’ve done my homework and ready when he finally agrees.

    You’re welcome!

    That media query at the end of the child theme’s stylesheet (line 87) is still missing a closing bracket, it may cause problems on smaller screens.

    Thread Starter timdevogel

    (@timdevogel)

    Ha, indeed. I’ve fixed that now. Thx.

Viewing 9 replies - 16 through 24 (of 24 total)
  • The topic ‘banner area after 1st post’ is closed to new replies.