Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have to load a couple of ads, some normal html and two are java script. I've tried the PHP method of this:

<?php $postnum++; if($postnum%10 == 0) { ?>
 <div id="topset">
  <ul id="top_ad_list">
      <?php dynamic_sidebar('botad'); ?>
  </ul>
 </div> 
<?php } ?>

What occurs is for the first pagination from the infinite scroll it will load the add, on the new loaded pages it will no longer load the ads.

The Infinite Scroll I am using as follows: Infinite Ajax Scroll

share|improve this question
    
How are the new posts on the infinite scroll page added? The code you've posted probably doesn't effect posts that are added dynamically later, so you'll need to add something in the loading function to include the advert. –  Simon Forster Sep 5 '12 at 11:36
1  
May the flying spaghetti monster bless AdBlock :) –  ThiefMaster Sep 5 '12 at 11:42
    
Thanks for the response, how would I go about doing that ? I am using github.com/webcreate/Infinite-Ajax-Scroll in place of infinite scroll. Most of the documentation is in there. –  espnicholas Sep 5 '12 at 11:56
    
I've replied in the form of an 'answer'. –  Simon Forster Sep 5 '12 at 12:17
    
Thanks, I'll look into see if I can solve a solution in the mean time. –  espnicholas Sep 5 '12 at 12:26
add comment

1 Answer 1

The solution to your problem is to add functionality using the onLoadItems event, whereby you inject an advert every time ten more items have been added, keeping track of the number of items loaded by adding the size of the items array passed when the event is triggered to a counter of some sort and when the counter hits 10, adding an advert and resetting your counter to 0.

From your response I'm assuming your level of JavaScript knowledge isn't that great? And also that you'd struggle to do this change even with the documentation provided with the script? Am I correct? Do you know what events are and how they work? If not, you could wait for someone to post a fully coded solution here, or raise your question as an issue on the GitHub issue tracker.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.