I've installed the Fancybox Plugin for Wordpress on a website. In normal pages, wheneaver I insert the Wordpress shortcode gallery or images, it works just fine.
But I have some pages where posts are loaded through an ajax function.
I know that, normally, the Fancybox Plugin scans the page for every image and then creates an attribute "rel='fancybox' on each of them. Therefore, if the page is already loaded and I add some content to it with AJAX, I don't expect the plugin to work, since it is triggered with de jQuery(document).ready statement.
How can I solve this issue? I thought of putting a str_replace function on the PHP function that is triggered by the AJAX call, like this:
$content = get_the_content();
// this will get the post_content and store it in the $content variable
$content = apply_filters('the_content', $content);
// this will make wordpress execute the shortcodes on the string $content
$content = str_replace('<a ', '<a rel="fancybox" ', $content);
// this SHOULD make the fancybox appear.
How can I solve this issue? Thanks a lot.