I added the Livefyre plugin for WordPress to a site I am working on in order to integrate Twitter and Facebook into the comments. The plugin works and looks great except for one thing. There isn’t an option to not display it when comments are disabled. Instead it displays the message, “Comments have been disabled for this post.”
I contacted support to see if there is a solution to my problem and received the following timely reply:
Hi Mike,
Thanks for the email. Currently we don’t have a method for hiding Livefyre all together on posts where comments are disabled, but that will be coming very soon. I will keep you posted on the status of the fix.
Cheers,
Jenna
I look forward to the promised fix, but that doesn’t help me today. I needed to figure out a solution for the current project I am working on that wouldn’t break a future fix from Livefyre.
This project is being developed using the Thesis premium theme for WordPress. After searching for ideas, and reading several, I was able to figure out a solution using a Thesis filter and added the following code to the custom_functions.php file.
function custom_body_class($classes) {
if( is_page())
$classes[] .= 'lf_comments_disabled';
return $classes;
}
add_filter('thesis_body_classes', 'custom_body_class');
I also added the WordPress conditional tag, is_page(), because I only want this to be suppressed for pages. The Thesis filter is called thesis_body_classes and it is used to add a custom class to the html body. The one I used is called lf_comments_disabled.
Now, all that is left is to add the following to the custom.css file.
/* Hide Livefyre on pages */
.lf_comments_disabled #lf_comment_stream {
display:none;
}
This turned out to be a simple solution. It could use more work to handle pages where you do want comments enabled, but on the particular site I am working on, this isn’t a requirement.
{ 5 comments… read them below or add one }
This is awesome! Exactly what I needed. Integrating a similar solution as an option for the LiveFyre plugin seems way to easy to continue to avoid. So many plugins have an option for where to display the widget.
Ryan, I always love it when I find code that helps me out. I hope it works well for you!
Mike
Thanks heaps for that Mike. You just saved me heaps of time!
You’re welcome!
We have written a plugin to solve this problem – it can be found in the WordPress Repository here :
http://wordpress.org/extend/plugins/livefyre-comments-have-been-disabled-for-this-post/
The plugin allows you to turn comments off on posts or pages on any well written theme (not just Thesis), and removes the disabled message and the surrounding LiveFyre graphics.
Please let me know if it works for you.