Profile Box Shortcode

Below, you’ll find a detailed guide on how to add the Profile Box Shortcode And Widget Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Profile Box Shortcode And Widget Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Profile Box Shortcode And Widget Plugin and the shortcodes it provides:

Plugin Icon
Profile Box Shortcode And Widget

"Profile Box Shortcode and Widget is a versatile WordPress plugin. It enables the seamless integration of a Facebook-like profile box into your website, as a widget or via shortcode."

★★★☆✩ (8) Active Installs: 3000+ Tested with: 6.2.3 PHP Version: false
Included Shortcodes:
  • [fblikebox]

Profile Box Shortcode And Widget [fblikebox] Shortcode

The ‘fblikebox’ shortcode from the Facebook-likebox-widget-and-shortcode plugin is used to display a Facebook like box on your website. It fetches data from a specific Facebook page URL, such as the page title, cover photo, and posts, and displays them in a widget.

Shortcode: [fblikebox]

Parameters

Here is a list of all possible fblikebox shortcode parameters and attributes:

  • id – Unique identifier for the Facebook Like Box
  • app_id – Facebook App ID for the Like Box
  • fb_page_url – URL of the Facebook page to display
  • title – If ‘true’, displays the WordPress post title
  • w_auto_width – If ‘true’, sets the width of the Like Box automatically
  • w_width – Sets a fixed width for the Like Box
  • w_height – Sets a fixed height for the Like Box
  • cover_photo – If ‘true’, displays the Facebook page’s cover photo
  • header_size – If ‘true’, displays a larger header for the Like Box
  • show_fans – If ‘true’, shows faces of people who like the page
  • show_post – If ‘true’, displays the Facebook page’s posts
  • language – Sets the language of the Like Box
  • credit_link – If ‘true’, displays a credit link for A WP Life

Examples and Usage

Basic example – Displaying a Facebook like box using the shortcode with a specific post id.

[fblikebox id=3 /]

Advanced examples

Displaying a Facebook like box with a specific post id and custom settings for the Facebook page URL, application ID, and widget title. It also sets the width and height of the widget, and whether to show the cover photo, header size, fans, posts, and credit link.

[fblikebox id=3 app_id="1869036243369971" fb_page_url="https://www.facebook.com/AWordPressLife/" title="true" w_auto_width="false" w_width="300" w_height="500" cover_photo="true" header_size="true" show_fans="true" show_post="true" credit_link="false" /]

Displaying a Facebook like box with a specific post id and custom settings for the language of the Facebook SDK. This example uses Spanish (‘es_ES’) as the language.

[fblikebox id=3 language="es_ES" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [fblikebox] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('fblikebox', 'awl_fb_shortcode');

Shortcode PHP function:

function awl_fb_shortcode($post_id) {
	ob_start();
	//load shortcode setting
	$id = $post_id['id'];
	if($facebook_cpt_settings = get_post_meta( $post_id['id'], 'facebook_cpt_settings'.$post_id['id'], true)) {
		//echo "<pre>";
		//print_r($facebook_cpt_settings);
		//echo "</pre>";
		$w_title = get_the_title($post_id['id']);
		if(isset($facebook_cpt_settings['app_id'])) $app_id = $facebook_cpt_settings['app_id']; else $app_id = "1869036243369971";
		if(isset($facebook_cpt_settings['fb_page_url'])) $fb_page_url = $facebook_cpt_settings['fb_page_url']; 	else $fb_page_url = "https://www.facebook.com/AWordPressLife/";
		if(isset($facebook_cpt_settings['title'])) $title = $facebook_cpt_settings['title']; else $title = "false";
		if(isset($facebook_cpt_settings['w_auto_width'])) $w_auto_width = $facebook_cpt_settings['w_auto_width']; else  $w_auto_width = "false";
		if(isset($facebook_cpt_settings['w_width'])) $w_width = $facebook_cpt_settings['w_width']; else $w_width = "";
		if(isset($facebook_cpt_settings['w_height'])) $w_height = $facebook_cpt_settings['w_height']; else $w_height = "";
		if(isset($facebook_cpt_settings['cover_photo'])) $cover_photo = $facebook_cpt_settings['cover_photo']; else $cover_photo = "true";
		if(isset($facebook_cpt_settings['header_size'])) $header_size = $facebook_cpt_settings['header_size']; else $header_size = "true";
		if(isset($facebook_cpt_settings['show_fans'])) $show_fans = $facebook_cpt_settings['show_fans']; else $show_fans = "true";
		if(isset($facebook_cpt_settings['show_post'])) $show_post = $facebook_cpt_settings['show_post']; else $show_post = "true";
		if(isset($facebook_cpt_settings['language'])) $language = $facebook_cpt_settings['language']; else $language = "en_US";
		if(isset($facebook_cpt_settings['credit_link'])) $credit_link = $facebook_cpt_settings['credit_link']; else $credit_link = "false";
		?>
		
		<?php if($title == 'true') { ?><h2><?php echo $w_title; ?></h2><?php } ?>
		<div id="fb-root"></div>
		<script>
		  window.fbAsyncInit = function() {
			FB.init({
			  appId      : '<?php echo $app_id; ?>',
			  xfbml      : true,
			  version    : 'v2.4'
			});
		  };
		(function(d, s, id) {
		  var js, fjs = d.getElementsByTagName(s)[0];
		  if (d.getElementById(id)) return;
		  js = d.createElement(s); js.id = id;
		  js.src = "//connect.facebook.net/<?php echo $language; ?>/sdk.js#xfbml=1&version=v2.4&appId=<?php echo $app_id; ?>";
		  fjs.parentNode.insertBefore(js, fjs);
		}(document, 'script', 'facebook-jssdk'));
		</script>
		<div class="fb-page" data-href="<?php echo $fb_page_url; ?>" data-width="<?php echo $w_width; ?>" data-height="<?php echo $w_height; ?>" data-small-header="<?php echo $header_size; ?>" data-adapt-container-width="<?php echo $w_auto_width; ?>" data-hide-cover="<?php echo $cover_photo; ?>" data-show-facepile="<?php echo $show_fans; ?>" data-show-posts="<?php echo $show_post; ?>"><div class="fb-xfbml-parse-ignore"><blockquote cite="https://www.facebook.com/facebook"><a href="https://www.facebook.com/facebook">Facebook</a></blockquote></div></div>
		<?php if($credit_link == "true") { ?><div id="awplife-credit-link" class="awplife-credit-link" style="font-size: x-small; margin-bottom:5px; margin-top:5px; width:100%; float: left;">Facebook Plugin By: <a href="https://awplife.com/" target="_blank">A WP Life</a></div><?php } ?>
		<?php
	}
	wp_reset_query();
	return ob_get_clean();
}

Code file location:

facebook-likebox-widget-and-shortcode/facebook-likebox-widget-and-shortcode/facebook-likebox-shortcode.php

Conclusion

Now that you’ve learned how to embed the Profile Box Shortcode And Widget Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *