AddToAny Share Buttons Shortcode

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

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

Plugin Icon
AddToAny Share Buttons

"AddToAny Share Buttons is a powerful WordPress plugin that enables users to share your content on any social media platform effortlessly. Enhance your site's engagement and reach with AddToAny."

★★★★☆ (1069) Active Installs: 400000+ Tested with: 6.3.2 PHP Version: 5.6
Included Shortcodes:
  • [addtoany]

AddToAny Share Buttons [addtoany] Shortcode

The AddToAny shortcode is designed to generate share/save buttons for your WordPress site. It uses the ‘addtoany’ function to create these buttons. The shortcode accepts four parameters – ‘url’, ‘title’, ‘media’, and ‘buttons’. These define the URL to be shared, the title of the shared content, the media file (if any), and the specific buttons to display. The output is a div element with the class ‘addtoany_shortcode’, containing the share/save buttons.

Shortcode: [addtoany]


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

  • url – Specifies the link to be shared.
  • title – Sets the title of the shared content.
  • media – Defines the media URL for the shared content.
  • buttons – Determines the sharing buttons to be displayed.

Examples and Usage

Basic example – A simple usage of the ‘addtoany’ shortcode with only the URL attribute defined.

[addtoany url=""]

Advanced examples

Utilizing the shortcode to share a specific URL with a custom title. The title will be displayed in the share options.

[addtoany url="" title="My Custom Title"]

Using the shortcode to share a specific URL with a custom title and designated media. The media attribute allows you to specify a media file to be shared along with the URL.

[addtoany url="" title="My Custom Title" media=""]

Adding custom buttons to the sharing options. The buttons attribute allows you to specify which sharing buttons should be displayed. The buttons should be specified as a comma-separated list.

[addtoany url="" title="My Custom Title" media="" buttons="facebook,twitter,linkedin"]

PHP Function Code

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

Shortcode line:

add_shortcode( 'addtoany', 'A2A_SHARE_SAVE_shortcode' );

Shortcode PHP function:

function A2A_SHARE_SAVE_shortcode( $attributes ) {
	$attributes = shortcode_atts( array(
		'url'     => '',
		'title'   => '',
		'media'   => '',
		'buttons' => '',
	), $attributes, 'addtoany' );
	$linkname =  $attributes['title'];
	$linkurl = $attributes['url'];
	$linkmedia = $attributes['media'];
	$buttons = ! empty( $attributes['buttons'] ) ? explode( ',', $attributes['buttons'] ) : array();
	$output_later = true;

	return '<div class="addtoany_shortcode">'
		. ADDTOANY_SHARE_SAVE_KIT( compact( 'linkname', 'linkurl', 'linkmedia', 'output_later', 'buttons' ) )
		. '</div>';

Code file location:



Now that you’ve learned how to embed the AddToAny Share Buttons 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.


Leave a Reply

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