Docs    Facebook    Customizations

Insert your own content every X number of posts

Add ads or content in between your Facebook posts.

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>');

Edit the variables on the first two lines to define how many posts to insert the content after and what content should be added. The content can be text or HTML.

If you need to only add the content to a specific feed then you can add a class to the shortcode:

Comments Box SVG iconsUsed for the like, share, comment, and reaction icons

And then target that feed in the fourth line of the snippet above:

$('.feed1 .cff-item').each(function(){

To add different content in every X number of posts you can use the following:

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>');

Couldn’t find your answer in the docs?

Contact Support

Was this article helpful?