请参见:http://infiniteajaxscroll.com/docs/events.html#rendered
因此,将所有ad代码放在ajax函数中(http://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_%28action%29)
add_action( \'wp_ajax_your_ad_fn\', \'your_ad_fn\');
add_action( \'wp_ajax_nopriv_your_ad_fn\', \'your_ad_fn\');
function your_ad_fn(){
// your ad code here
// if sending js, set Content-type header to application/javascript
// if sending html, text/html
}
https://stackoverflow.com/questions/9664282/difference-between-application-x-javascript-and-text-javascript-content-types
然后在自定义js中,
ias.on(\'rendered\', function(items) {
var $items = $(items);
jQuery.get(
\'http://yoursite.com/wp-admin/admin-ajax.php\', // I\'ve just illustrated, don\'t write the url directly, do it via wp_localize_script
).done( function( data ) ){
$items.after(data); // append ad after all the loaded posts
});
})
这是
NOT 确切的代码,你必须自己解决一些细节。