Re: {MSPWP} Loading additional code with infinite scroll

195 views
Skip to first unread message

Nicholas Ciske

unread,
Jun 11, 2013, 12:02:44 PM6/11/13
to mpls-stpau...@googlegroups.com
I've used it on a site or two.

You can go 2 routes here:

Add it via PHP (e.g. a filter) at the bottom of each page of posts, inside the 'posts' container (so it gets inserted by the plugin). This will work for non JS users as well.

OR

By passing in a custom 'complete' callback and inserting the ad via jQuery at that point. I know that's a simple matter in Genesis -- YMMV with other themes.

(see Callback Function)

(see How do I pass additional arguments such as callbacks to the Infinite Scroll script?)

_________________________
Nick Ciske
@nciske


On Jun 11, 2013, at 10:47 AM, Marty Kokes wrote:

Hi Everyone,

I'm wondering if anyone has any experience with the infinite scroll plugin and inserting some additional code each time a new 'page' of posts is retrieved. I'm going to be inserting an ad slot but essentially it could be anything.

Thanks,
Marty

Nicholas Ciske

unread,
Jun 12, 2013, 6:52:27 PM6/12/13
to mpls-stpau...@googlegroups.com
Looks fine to me. It's an additional Ajax request, but as long as it doesn't block/slow down loading of the posts, that shouldn't be an issue. 

Sent from my iPhone 5

On Jun 12, 2013, at 10:54 AM, Marty Kokes <mko...@gmail.com> wrote:

Thanks Nick!

That's just what I was looking for I opted for the jQuery method. I'm somewhat of a novice when it comes to jQuery / javascript so I'm not sure if I went about it the best way, but within the infinite scroll plugin settings there's an option box for a callback.

Since I'm bringing in a chunk of posts and I only want to insert the code once per chunk and not after ever post I used .after() to insert a div after the 'loading new posts' graphic. Then used .load() to insert my ad code into the div I just added.

Does this seem right? It's working I'm just curious if I went about the code the right way.

jQuery('#infscr-loading').after('<div class="isad"></div>');
jQuery('.isad').load("/wp-content/themes/base/includes/infinitead.php");

Thanks again,
Marty
--
You received this message because you are subscribed to the Google Groups "Minneapolis St. Paul WordPress User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mpls-stpaul-word...@googlegroups.com.
To post to this group, send email to mpls-stpau...@googlegroups.com.
Visit this group at http://groups.google.com/group/mpls-stpaul-wordpress?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages