Owned by LinkedIn , SlideShare is web based slide hosting service that allows users to upload files privately or publicly in PowerPoint, PDF, Keynote or OpenDocument formats. Those presentations can then be viewed on the website, mobile applications, or embedded into other websites. The website receives an estimated 58 million unique visitors a month, and has about 16 million registered users, making it one of the most used platforms for education and training.
The primary means of obtaining SlideShare data is via their feature-rich API . The code on this page, however, will fetch oEmbed data and extract the necessary information to render a presentation. Given the large number of our clients that are starting to use LinkedIn (and SlideShare), an API article will likely follow.
The Result
Using the shortcode of [slideshare v="http://www.slideshare.net/haraldf/business-quotes-for-2011"]
the following slideshow will show in your WordPress website (where v is the full slideshow URL).
If you wish to exclude the description that sits underneath the slides, use [slideshare v="http://www.slideshare.net/pohjus/introduction-to-php-presentation" description="0"]
(meaning description is false). The result is as follows:
To change the way the default footer displays, you should alter the HTML in the shortcode function and style your own attribution footer.
Shortcode Attributes
v
v
refers to the full SlideShare presentation URL. We've used 'v' only because it's consistent with our video shortcodes.width
w
, should be hard coded into the shortcode function so that you don't have to specifically define it every time you embed a presentation.height
h
(height) is automatically scaled based on your width. If our scaling doesn't quite work, you should tweek it by defining the height yourself. The height can almost always be left blank.description
d="0"
(meaning description = false). If description="0"
it'll be just the iframe presentation that'll be displayed on your page.cache
cache
defines the amount of time data is stored locally in your WordPress database before a fresh request is made for SlideShare data. Because data is rarely altered by SlideShare authors, updating it once every couple of months is normally sufficient. Alter it as required.The Code
Copy and paste the WordPress function into your theme's functions.php
file or, if you sensibly have one installed, your custom functions plugin.
If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.
PHP Function
A PHP function is included as a download below. Usage requires Simple Cache.
Considerations
- We initially wrote code that stored the data as an option (rather than using the transient API). Because SlideShare gives authors the option to update and edit their presentations, we decided to cache the result for a period of time using the transient API so that we can periodically update data. If the presentation itself is updated before the cache expires, the new presentation will continue to be shown (you can force a new request by altering the cache time).
- While there's a default "out-of-the-box" embed code returned in SlideShare's JSON response, we've chosen to rebuild it so we can have full control over how the slideshow is styled.
- We retrieve all the data returned by SlideShare but only cache the resulting HTML. You have access to all returned data so you can easily build your own title area.
- SlideShare have an API at slideshare.net/developers that provides more advanced features. We'll look at the API in the future.
Download
Title: Embed SlideShare Presentations (WP Shortcode)
Description: Embed SlideShare Presentations into WordPress with Shortcode or PHP.
Download • Version 0.2, 1.5K, zip, Category: WordPress Shortcodes
PHP Code & Snippets, (1.6K)