• Resolved alevalentini

    (@alevalentini)


    So, I’m using this nice plugin for my news website, in the category pages. I need to put DoubleClick Google banners between the post teasers. I added the code to the repeater.

    Point is I want to load them only the “first time”. I want them not to be loaded when the plugin “loads more” posts.

    But, being ajax, every load is simultaneous, so I cannot use php vars to check it.

    What can I do? I do not know how to use ajax. Is there a way to store a variable and check it in order not to load the banners the second, third, fourth, etc.. time around?

    https://ww.wp.xz.cn/plugins/ajax-load-more/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Sorry for the delay, I must have missed this request…
    Of the top of my head you could use javascript to update a variable every time the ajax complete function is triggered.
    http://api.jquery.com/ajaxcomplete/

    Is using javascript a possibility?

    Thread Starter alevalentini

    (@alevalentini)

    Yes indeed. I guess that it’s the only way, because the action is client-side. You added an ajax check, didn’t you? How should I use it? Thanks for the help man!

    Plugin Author Darren Cooney

    (@dcooney)

    Yes I did!
    Something like this:

    var init = true;
    $.fn.almComplete = function(alm){
        if(init){
           // Your doubleclick action
           init = false;
        }
    }

    You would add this to your global JS file.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Code to be shown only in the first load’ is closed to new replies.