You can use the output filter to modify what’s included with each post listed by this plugin. Here’s a tutorial with more information: https://www.billerickson.net/code/using-display-posts-shortcode-output-filter/
As far as integrating Social Warfare, you’ll need to ask their support for the best method. Two issues you may run into using the social_warfare() function:
1. It’s designed to display (echo
) the share buttons rather than return
it. You might have all the social share buttons appear (multiple times) at the top of the page you insert the shortcode in. To get around this, you may need to output buffer the function or find a social warfare function that returns rather than echoes the result.
2. It may show the share buttons for the current page (ie: the one with the shortcode embedded in it) rather than the post shown in Display Posts Shortcode.
By the way, I’m also one of the developers of Shared Counts, a free social sharing plugin similar to Social Warfare.
While it’s not currently possible to include Shared Counts in display posts shortcode (issue #2 above), it should be possible with the next release. For more information on this improvement (and example code on how to add it to your site), see here: https://github.com/jaredatch/Shared-Counts/issues/45
Thanks for the in-depth reply! I’ll look into Shared Counts. We’ve been having issues with Social Warfare anyway.
Hey Bill,
We are now using Shared Counts. You mentioned above that the functionality to include Shared Counts in display post shortcode was coming. How would I implement that?
Here you go: https://www.billerickson.net/code/shared-counts-display-posts-shortcode/
Once you add that to your theme’s functions.php file or a core functionality plugin, you can use: [display-posts include_shared_counts="true"]
to display the buttons.
You can change the style using the shared_counts_style attribute. Ex: [display-posts include_shared_counts="true" shared_counts_style="icon"]
It’s set to display the share buttons at the very top of the listing item. You can change this position by moving the $share
variable in line 22, where the output is re-assembled.
I think that the snippet on this page (https://www.billerickson.net/code/shared-counts-display-posts-shortcode/) is missing a paren on line 12. I was getting an unexpected return error and counted opening and closing () and added one and it’s working now.