• Resolved Veken

    (@veken)


    Is there a php function that can be used to load the share buttons in a specific location in the theme. Similar to the Shortcode, but to be used in the theme php file directly.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Bill Erickson

    (@billerickson)

    Yes, you can use this:

    
    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 code for more information: https://github.com/jaredatch/Shared-Counts/blob/develop/includes/class-shared-counts-front.php#L322

    • This reply was modified 6 years, 8 months ago by Bill Erickson.
    Thread Starter Veken

    (@veken)

    Thank you!

    I think the code is just missing a closing ) at the end.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Set location of Share Buttons in theme php file’ is closed to new replies.