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>');
  i++;
});

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

3 weeks ago

Smash Balloon

Ever wanted to showcase your YouTube live streams on your website?

Here's a quick video tutorial to help you:
▶️
... See MoreSee Less

Video image

Comment on Facebook

3 months ago

Smash Balloon

Check out MemberPress and the new ChatGPT integration!The Uncanny Automator-powered #MemberPress + OpenAI ChatGpt Integration is HERE! 🚀

Turn your ⏰ time-consuming content-creating tasks over to #ChatGPT & put AI to work for your WordPress online business 👉 memberpress.com/cgpt-guide
... See MoreSee Less

Check out MemberPress and the new ChatGPT integration!

3 months ago

Smash Balloon

Want to easily embed reviews from Google, Facebook, Tripadvisor, and Yelp on your WordPress website?

Find out how to do this in just 4 minutes in our video tutorial:
... See MoreSee Less

Video image

Comment on Facebook

We have a problem. It's impossible connect the account ig. Help me please

Load more

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>');
     count++;
   }
   i++;
});
support

Couldn’t find your answer in the docs?

Contact Support

Was this article helpful?