Excluding some posts and articles from not showing up comments


I have made a CPT (Custom Post Type) and i want to exclude some posts for not showing up the comments. Means some posts should never show any facebook comments option. How to implement this?

  • Nastia

    Hello Saad

    I hope you are doing well today!

    At the current time there is no option in Ultimate Facebook plugin to exclude or include importing comments for custom post types.

    Let me flag our second level support here to give you further directions on this. Please note, that the developer reply might take longer than the usual staff.

    We appreciate your patience on this.

    All the best,

  • Panos

    Hello Saad ,

    As Nastia mentions the plugin does not provide any options for this, at least for now :slight_smile:

    The quickest and easiest way to do this would be do make a small change in a plugin's file. This is generally not a recommended method (editing core files) as these files will be replaced with plugin updates so you will have to repeat this every time this plugin gets a new update.

    I suggest this as I don't see any hook available to override default functionality. So, the file you need to edit is wp-content/plugins/wpmu-dev-facebook/wdfb_utilities.php

    Go to line ~402 and before this part:
    return apply_filters( 'wdfb-tags-use_html5', $is_html5 ) ? wdfb_get_fb_plugin_markup_html5( $type, $args ) : wdfb_get_fb_plugin_markup_xfbml( $type, $args );
    you can add

    global $post;
    $no_comments_list = array( 10, 22, 75, 143 );//Specify id's here
    if( in_array( $post->ID, $no_comments_list ) ) return;

    In the array above insert the CPT id's that you DON'T want to show FB comments.

    You may also exclude the comments to show to all posts of CPT by using
    if ( $post->post_type == 'yourcpt') return;

    Please let us know if need further assistance implementing this snipped.

    Kind regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.