Thread Starter
okiwan
(@okiwan)
All right, I think I found a solution. Of course it’s not an elegant one, but at least it works flawlessly on any situation and avoid any kind of coupling (if this is a right term) between my theme and the plugin.
The problems is that, by using get_the_content(), WordPress does not apply any filters to it. It only does it using the_content(). So, what we are going to do is use it.
As we know the_content prints on screen but, what happens if we put this onto a temporary buffer? PHP function ob_start() creates an output buffer, which will held the contents without displaying them, and those contacts will be affected by the filters for sure. Finally, we will call ob_get_clen() to retrieve and store them in a variable and clean the buffer. Pretty neat. Here’s all together:
// Whatever you have to do here...loop, etc.
ob_start();
the_content();
$theOutput = ob_get_clean();
// ...whatever you have to do with the output, now with all filters applied (and, on this case, with lightbox working flawlessly
Cheers!
Output buffering will do the trick.
Alternatively, if you want more control over the content, you can manually apply the filters hooked into the_content (such as SLB):
$my_content = apply_filters('the_content', get_the_content());
In general though, get_the_content() is primarily useful for when you want the raw/unfiltered content, not just when you don’t want it to be output to the browser. the_content() does additional processing to the content to prepare it for display, so output buffering may be the better option in your case.