You can set Shared Counts to automatically insert the buttons before and/or after the content of your page. The hook or filter used will depend upon your theme (see the code here):
- If you are using a Genesis theme:
- “Before” uses the
genesis_entry_header
hook with a priority of 13 - “After” uses the
genesis_entry_footer
hook with a priority of 8
- “Before” uses the
- If your theme supports the Theme Hook Alliance:
- “Before” uses the
tha_entry_top
hook with a priority of 13 - “After” uses the
tha_entry_bottom
hook with a priority of 8
- “Before” uses the
- If you are using any other theme:
- “Before” uses the
the_content
filter with a priority of 8 - “After” uses the
the_content
filter with a priority of 12
- “Before” uses the
Change location
You can modify these locations using the shared_counts_theme_locations
filter.
Let’s say you have added a hook to your theme for your post intro:
do_action( 'be_post_intro' );
Code language: JavaScript (javascript)
You could tell Shared Counts to use this hook for the “Before” location like so:
This code snippet goes in a core functionality plugin or Code Snippets.
/**
* Move Shared Counts
* @see https://sharedcountsplugin.com/2019/03/27/change-the-theme-location-for-share-buttons/
*
* @param array $locations
* @return array
*/
function be_shared_counts_location( $locations ) {
$locations['before']['hook'] = 'be_post_intro';
$locations['before']['filter'] = false;
return $locations;
}
add_filter( 'shared_counts_theme_locations', 'be_shared_counts_location' );
Code language: PHP (php)
Filters used:
shared_counts_theme_locations