Support » Plugin: A-Z Listing » Works great, but can I integrate ad space?

  • Plugin works very well on my site. Thank you! I would however like to insert add banners, after every say 50 lines or so. Any way I can do this?

    Thanks again!

Viewing 1 replies (of 1 total)
  • Plugin Author Daniel Llewellyn


    Hi, Yes this is possible if you want to work with the PHP.

    Specifically, the entire output is customisable via copying the file from <plugindir>/templates/a-z-listing.php into your theme (or child theme if you are using a theme you did not create yourself, to ensure that updates don’t replace any customisations you make). The template file works like a standard WordPress loop but has two loops instead of one, which are nested one inside the other.

    You will want to add a counter variable set to 0 outside the loop you want to interrupt and then increment it inside that loop. Once you’ve incremented the value you will want to test that it is divisible by the constant you choose – in your example above this was 50 – and then output your interruption.

    Example structure follows:

    <?php while ( $a_z_query->have_letters() ) : $a_z_query->the_letter(); ?>
        <?php if ( $a_z_query->have_items() ) : ?>
            <?php $interruptionCounter = 0; ?>
            <?php while ( $a_z_query->have_items() ) : $a_z_query->the_item(); ?>
                <?php if ( 0 === $interruptionCounter++ % 50 ) : ?>
                    ... Your banner here ...
                <?php endif; ?>
                ... Rest of loop here ...
            <?php endwhile; ?>
        <?php endif; ?>
    <?php endwhile; ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Works great, but can I integrate ad space?’ is closed to new replies.