WordPress.org

Forums

FaceBook Like Button Plugin for WordPress
FBLike Shortcode (1 post)

  1. Aaron Brown
    Member
    Posted 3 years ago #

    In case anyone wants to put this like button on only specific pages, here is a simple way to add a shortcode for this plugin.

    Add this code into your theme's functions file.

    function wm_fblike_shortcode(){
    
    	$button = null;
    
    	if(function_exists('fblike_get_iframe')){
    
    		$fblike_uri = get_permalink(get_the_ID());
    
    		$button = fblike_get_iframe($fblike_uri);
    
    	}
    
    	return ($button);
    
    }
    add_shortcode('fblike','wm_fblike_shortcode');

    Then, you can use the shortcode [fblike] in any post, page, or custom post type. If you'd like to use it in your template files, insert the following code into your template where you'd like to see the button.

    <?php echo do_shortcode('[fblike]');?>

    One usage note: if you're using the shortcode or template tag, you'll have to select the appropriate combination of "FBLikeButton Settings" on the plugin settings page to avoid showing the button more than once on your page.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • FaceBook Like Button Plugin for WordPress
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

  • RSS feed for this topic
  • Started 3 years ago by Aaron Brown
  • This topic is not a support question
  • WordPress version: 3.2.1