How to display Social Warfare sharing buttons when content limit is set in Genesis

Posted on

In the members-only forum a user asked:

Does anyone know how to manually add social sharing icons to the blog index and category pages? I am using a plugin called “Social Warfare,” which allows for manual placement, but I don’t know where to hook it in. It shows just fine on pages and posts, but I want the icons to show below each post in the index and category pages. I know this particular plugin is a specific situation, but I’m assuming it would be the same for similar social sharing plugins.

Social Warfare is a fantastic plugin for displaying social sharing buttons in your WordPress site. While the plugin does have built-in setting to make the social buttons automatically appear above or below or both above and below the content on archives, this auto placement does not work when content limit is set in Genesis‘ theme settings.

Notice that the content is set to be limited to 140 characters.

In spite of Display Locations > Location sitewide set to say, ‘Below the Content’ in Social Warefare’s settings, the social sharing buttons will not appear unless the following code is added to child theme’s functions.php:

// Display Social Warfare sharing buttons below content when content limit is set
add_action( 'genesis_entry_content', 'sk_social_warfare' );
function sk_social_warfare() {

	// if we are on a single page, abort.
	if ( is_singular() ) {
		return;
	}

	// if Social Warfare plugin is active, display its sharing buttons
	if ( function_exists( 'social_warfare' ) ) {
    		social_warfare();
	}

}