wp_connect_comments

Description

The wp_connect_comments function renders a Facebook Comments based on the specified setting values. It can be used by theme designers who would like to add specific comment box(es) to their theme.

Usage

<?php wp_connect_comments(
$href, $width, $number_of_comments
, $colorscheme, $echo
); ?>

Parameters

$href
(string) (required) . The URL for the comments box.
Default: None. Pass an empty string for the current page.
$width
(integer) (required) The width of the plugin in pixels.
Default: None
$number_of_comments
(integer) (required) The number of comments to display by default.
Default: None
$colorscheme
(required) The color scheme of the plugin.
Valid Values: WPC_THEME_LIGHT, WPC_THEME_DARK
Default: None
$echo
(boolean) (optional) Whether to print the plugin code (TRUE) or return it as a PHP variable (FALSE).
Default: TRUE

Examples

Default Usage

Prints the Comments box.

// this file is required to enable the use of WordPress Connect constants
$wpc_constants_file = WP_PLUGIN_DIR . '/wordpress-connect/src/WordpressConnectConstants.php';

if ( file_exists( $wpc_constants_file ) && function_exists( 'wp_connect_comments' ) ){
	require_once( $wpc_constants_file );

	$comments_url = 'http://www.mysite.com/my-post';
	$number_of_posts = 10;
	$comments_width = 480;
	$colorscheme = WPC_THEME_DARK; // or WPC_THEME_LIGHT

	// render the comments box in place
	wp_connect_comments(
		$comments_url,
		$number_of_comments,
		$comments_width,
		$colorscheme
	);
}

When using wp_connect_comments in the loop you can use the following code to set the href parameter to the post’s url

// this file is required to enable the use of WordPress Connect constants
$wpc_constants_file = WP_PLUGIN_DIR . '/wordpress-connect/src/WordpressConnectConstants.php';

if ( file_exists( $wpc_constants_file ) && function_exists( 'wp_connect_comments' ) ){
	require_once( $wpc_constants_file );

	$comments_url = get_permalink(); // must be inside the loop
	$number_of_posts = 10;
	$comments_width = 480;
	$colorscheme = WPC_THEME_DARK; // or WPC_THEME_LIGHT

	// render the comments box in place
	wp_connect_comments(
		$comments_url,
		$number_of_comments,
		$comments_width,
		$colorscheme
	);
}

Change Log

Source File

wp_connect_comments() is located in wordpress-connect/wordpress-connect-functions.php.

Related

wp_connect_activity_feed, wp_connect_comments_default, wp_connect_facepile, wp_connect_like_box, wp_connect_like_button, wp_connect_like_button_default, wp_connect_live_stream, wp_connect_login_button, wp_connect_recommendations, wp_connect_send_button