6olden
6olden

Reputation: 121

Missing elements (Facebook Like button) when using Ajax pagination

I'm trying to help a good friend out with his site. I did not make this site so I'm diving into the deep, I am also new with WP. He wants a new audio player and Ajax pagination.

So far I did everything manually. It's a rough start though. I just load the next page with Ajax and fetch a div from that page.

My problem is: all posts contain a Facebook Like button and a Tweet button at the bottom. Now when I load the next page of posts (the div), those buttons disappear. I guess it has to do with plugins that are being loaded when the page itself is loaded. It is also missing the number of comments. These are Facebook comments also. To be honest I have no idea how to fix this...

Edit: Ok, I'm pretty sure I somehow need to reload that plugin in the Javascript chain... is that possible?

You can check it out at

Is there a better way? Am I actually doing it right? Is there a plugin that makes this easier? Again, I did not make this site and it's my first time using WP. I have no idea where to find the page settings (which might contain the max posts per page etc.)

Thanks in advance, I hope I am clear, if not, please say.

Upvotes: 0

Views: 196

Answers (1)

kobra
kobra

Reputation: 150

What you need to do is refresh the Facebook plugins after loading dynamic content with Ajax. Here's a snippet of code I used on a project:

// Run this on your Ajax callback
try{
    // This code reloads the Facebook plugins
    FB.XFBML.parse(); 
}
catch(ex){
    // Something went wrong
}

The code requires you to load the Facebook API (duh!).

Upvotes: 1

Related Questions