How to add social sharing to documents
Sometimes, it can be a good idea to allow people to share your document library - or individual documents - via email or to their social networks. This article explains how to do both.
Add social sharing for the document library page
To allow people to share your entire document library page, you can use any WordPress social sharing plugin which supports pages. Simply install the plugin and make sure the social sharing buttons are enabled on pages. This includes your main document library page, and any other page where you have used a shortcode to list documents.
If you want to display the social sharing links on your document library page but not elsewhere on your site, then you can do this using a social sharing plugin that provides a shortcode. For example, the free Social Media Share Buttons & Social Sharing Icons plugin has a
[DISPLAY_ULTIMATE_SOCIAL_ICONS] shortcode which inserts the sharing buttons manually. For example, you could add this to the top or bottom of your main document library page.
Add social sharing links to individual documents
You might also want to allow people to share individual documents in the library. The best way to do this is by adding the buttons to the main content of the single document page. You can do this using the
[DISPLAY_ULTIMATE_SOCIAL_ICONS] shortcode that comes with the free Social Media Share Buttons & Social Sharing Icons plugin:
The buttons will look like this on the single document page, depending on which social icons you have enabled and which style you have chosen for them:
- If you don't want to manually add a shortcode for each document then you could insert it programmatically. This requires developer-level knowledge.
- If you want to display the same social sharing icons on your main document library page, then you can do this by showing the 'content' field in the document table or grid. You must also enable the 'Shortcodes' option in Documents → Settings, otherwise the shortcode won't appear. However, if you do this then the social sharing buttons for each document will share links to the main document library page and not the individual document. You would need to do some custom coding in order to programmatically change the URL for each document in the list. As a result, we recommend having the buttons on the single document page instead, where they will link to the URL for that specific document.