Social Share Buttons & Analytics Shortcode

Below, you’ll find a detailed guide on how to add the Social Share Buttons & Analytics 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 Social Share Buttons & Analytics Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Social Share Buttons & Analytics Plugin and the shortcodes it provides:

Plugin Icon
Social Share Buttons & Analytics Plugin – GetSocial.io

"Social Share Buttons & Analytics Plugin – GetSocial.io is a powerful WordPress tool, streamlining social sharing and analytics. It simplifies social engagement tracking and enhances the user experience."

★★★★✩ (154) Active Installs: 5000+ Tested with: 6.3.2 PHP Version: 5.2.4
Included Shortcodes:
  • [getsocial]

Social Share Buttons & Analytics [getsocial] Shortcode

The ‘getsocial’ shortcode from the wp-share-buttons-analytics-by-getsocial plugin is used to display social sharing bars. It checks if the page is a single post, a page, or a shop page. If it matches, it generates the social sharing bars using the ‘follow_bar’ app. If not, it returns an empty string.

Shortcode: [getsocial]

Parameters

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

  • app – specifies the type of social share bar to display

Examples and Usage

Basic example – Displaying the follow bar on a single post or page by using the ‘app’ attribute.

[getsocial app="follow_bar" /]

Advanced examples

Displaying the follow bar on a single post or page, while specifying the post’s permalink and title. This is useful when you want to customize the link and title associated with the follow bar.

[getsocial app="follow_bar" permalink="http://example.com/post" title="My Custom Title" /]

Displaying the follow bar on a single post or page, while specifying the post’s permalink, title, and thumbnail image. This is useful when you want to customize the link, title, and image associated with the follow bar.

[getsocial app="follow_bar" permalink="http://example.com/post" title="My Custom Title" thumbnail="http://example.com/image.jpg" /]

PHP Function Code

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

Shortcode line:

add_shortcode('getsocial', 'gs_bars_shortcode');

Shortcode PHP function:

function gs_bars_shortcode($atts) {
    global $wp_query;
    $post = $wp_query->post;
    $GS = get_gs();

    if (function_exists('is_shop')) {
        $shop_page = is_shop();
    } else {
        $shop_page = false;
    }

    // if no type defined
    if ($atts['app'] == 'follow_bar' || (array_key_exists('app',$atts) && (is_single() || is_page() || $shop_page))) {
        return $GS->getCode($atts['app'], get_permalink(), get_the_title(), wp_get_attachment_url( get_post_thumbnail_id($post->ID)));
    } else {
        return "";
    }
}

Code file location:

wp-share-buttons-analytics-by-getsocial/wp-share-buttons-analytics-by-getsocial/wp-share-buttons-analytics-getsocial.php

Conclusion

Now that you’ve learned how to embed the Social Share Buttons & Analytics 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 *