B
B
Boris Belov2018-11-12 17:24:41
contextual advertising
Boris Belov, 2018-11-12 17:24:41

How to make YAN ads appear after (cycle) every three posts?

Good day.
You need to do something like this, only with YAN from Yandex
Wu175.png
. Now the following is obtained,
5be98cbb13a87820778748.png
that is, now it is displayed only after the second post, and then the block under YAN is empty. and does not want to be displayed.
The blocks themselves are displayed like this

<?php if ( $postcounter % 6 == 2 ) : ?>
<?php get_template_part('loop', 'reklama' ); ?>
          <?php endif ?>

<div class="item reklama">
            <div class="wrap">
<!-- Yandex.RTB R-A-327587-1 -->
<div id="yandex_rtb_R-A-327587-1"></div>
<script type="text/javascript">
    (function(w, d, n, s, t) {
        w[n] = w[n] || [];
        w[n].push(function() {
            Ya.Context.AdvManager.render({
                blockId: "R-A-327587-1",
                renderTo: "yandex_rtb_R-A-327587-1",
                async: true
            });
        });
        t = d.getElementsByTagName("script")[0];
        s = d.createElement("script");
        s.type = "text/javascript";
        s.src = "//an.yandex.ru/system/context.js";
        s.async = true;
        t.parentNode.insertBefore(s, t);
    })(this, this.document, "yandexContextAsyncCallbacks");
</script>
            </div>
          </div>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikita, 2018-11-12
@SweetBubaleh

Googled poke

A
Alexander, 2018-11-12
@apisklov

if the ad block code is in a loop, then you have several blocks with the same id displayed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question