You can call the display method within your theme or plugin file to include the share buttons. The “function exists” part ensures this code only runs if Shared Counts is active.
if( function_exists( 'shared_counts' ) {
shared_counts()->front->display();
}
You can also pass the following parameters to the display method:
- Location (adds a CSS class to the shared-counts-wrap so you can apply location-specific styling)
- Echo, whether you want it to echo or return the markup
- Style, specify a button style for this location, overriding the site-wide default style
- Post ID, specify a post ID different than the current post (ex: for a custom loop)
For instance, if you wanted to add a “sidebar-top” location that uses the icon style (different from the style you specified in Settings > Shared Counts) you can use this:
if( function_exists( 'shared_counts' ) {
shared_counts()->front->display( $location = 'sidebar-top', $echo = true, $style = 'icon' );
}
See the source code for more information.