Facebookの投稿の間に広告やコンテンツを追加する。
var number_of_posts = 5,
content_to_add = 'Add content here',
i = 1;
$('#cff .cff-item').each(function(){
if( i % number_of_posts == 0 ) $(this).after('<div class="cff-item">'+content_to_add+'</div>');
i++;
});
最初の2行の変数を編集して、いくつの投稿の後にコンテンツを挿入するか、またどのようなコンテンツを追加するかを定義する。コンテンツはテキストでもHTMLでも構いません。
特定のフィードにのみコンテンツを追加する必要がある場合は、ショートコードにクラスを追加することができます:
Load more
そして、上のスニペットの4行目にあるフィードをターゲットにする:
$('.feed1 .cff-item').each(function(){
X回の投稿ごとに異なるコンテンツを追加するには、次のようにします:
var number_of_posts = 5,
content_to_add = [
'Content 1',
'Content 2',
'Content 3'
],
i = 1,
count = 0;
$('#cff .cff-item').each(function(){
if( i % number_of_posts == 0 && count < content_to_add.length ){
$(this).after('<div class="cff-item">'+content_to_add[count]+'</div>');
count++;
}
i++;
});
