WordPress.org

Ready to get started?Download WordPress

Forums

Facebook
[resolved] How to show Comments only on certain pages? (12 posts)

  1. tnguyen14
    Member
    Posted 1 year ago #

    How can I show the Facebook comment box on certain pages only?

    There's a setting from the plugin that will display this on all pages, but I don't know how to display it for like a couple pages.

    http://wordpress.org/extend/plugins/facebook/

  2. zackcello
    Member
    Posted 1 year ago #

    I am trying to find out the same thing! I want to have comments available on certain posts...

  3. Niall Kennedy
    Member
    Plugin Author

    Posted 1 year ago #

    You can try adding your own conditionals to trigger a comments_template filter override.
    http://plugins.trac.wordpress.org/browser/facebook/tags/1.3/facebook.php#L337

    The plugin scopes by post type. You can disable Comments Box for all post types but add it back for a post_id by replicating the code after checking is_single in your custom code.

  4. benklocek
    Member
    Posted 1 year ago #

    Why not respect the "Discussion: Allow comments." checkbox on pages/posts?

    In plugins/facebook/socialplugins/comments.php, a simple check for comments_open() would suffice. There's not a filter or hook there to do anything with at the moment, but it would tie in to the expected behavior.

  5. zackcello
    Member
    Posted 1 year ago #

    benklocek: That sounds like a brilliant, easy, quick fix! So what would the entire added line of code look like?

  6. zackcello
    Member
    Posted 1 year ago #

    Niall: The only issue with that, is what if I want just one post from the same post type to not have comments? benklocek's idea of having the plugin linked to the current WordPress "Allow Comments" option seems like the easiest and best solution for you. And it seems like a really quick fix, too, no?

  7. benklocek
    Member
    Posted 1 year ago #

    Looks like Facebook::comments_box() (ln. 499 of class-facebook-comments.php) is checking if comments are open, but for some reason it's not respecting it. The code comments are a bit cryptic, so I'm not yet sure why it's not working.

  8. benklocek
    Member
    Posted 1 year ago #

    If I test comments_open() in my page template, it returns false, but in the plugin, it returns true. Same postID.

  9. Niall Kennedy
    Member
    Plugin Author

    Posted 1 year ago #

    Comments Box displays both existing comments and encourages new comments. have_comments() and comments_open() wrapped into one.

    By default the plugin fetches comments from Facebook servers to include inside a noscript element on the page. If that request comes back with no comments then the plugin acting on the comments_open filter by always returning true is removed.

  10. benklocek
    Member
    Posted 1 year ago #

    @naill, thanks for the clarification. It seems that even if there are no comments from FB, it still gets added to the page.

  11. zackcello
    Member
    Posted 1 year ago #

    Just to let you guys know, I deleted the Facebook plugin and switched to Discus. It works easily as pie, and I can uncheck "Allow comments" under Discussion on a post and the comments disappear, just like I want.

  12. benklocek
    Member
    Posted 1 year ago #

    @naill It seems that even if there are no comments from FB, it still gets added to the page. Even If I have a new page, that has never had comments on, they get displayed.

    I've tried filtering "facebook_comments_wrapper", so it doesn't pull any thing from FB, but that's doesn't prevent it from loading also.

    Thoughts?

    "Not Resolved"

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags