Of all the LinkedIn shortcodes we've shared in the past, this would have to be the most pointless. However, because our own company policy dictates we never use 'default' embed code for anything, we wrote a shortcode to embed LinkedIn posts some time back.
The nature of LinkedIn embeds means that the height of the embedded content is a variable. So since there's no means of determining what that height should be without looking at the iframe embed code, it must be defined in every single shortcode we use. The width tends to be fixed at 504 pixels but that's also something that might change from post-to-post. The usefulness of shortcodes comes from using as few attributes in the code as possible, and it's the inclusion of the height
that makes this particular shortcode a little annoying.
Our shortcode really doesn't do much other than center the content in your WordPress post container, and it provides a future-proof means of altering the embed code should it ever change in the future.
The Result
The result is the same as simply embedding the naked embed code. The shortcode of [linkedin id="urn:li:ugcPost:6449845260351836160" height="578"]
returns the video post below. Note that we've included the post ID and the height. You may optionally include the full post URL although we'd recommend against it. If the width is anything other than 504
you'll have to also include the width as a shortcode attribute.
■ ■ ■
Widget included with a shortcode as provided here.
WordPress Shortcode
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.
Shortcode Attributes
The following shortcode attributes apply.
url
url
is either the full post URL or the post ID (at the end of the URL string). For future-proofing purposes it's best just to use the ID.height
width
width="518"
).Considerations
- The LinkedIn embed container is responsible on mobile devices by default.
- We will share another version shortly that automatically determines height and width, but it's a little more complex.
- LinkedIn URN namespace information can be found here .
Download
Title: Embed LinkedIn Content In WordPress With Shortcode
Description: Embed A LinkedIn Video Or Post In WordPress With Shortcode.
Download • Version 0.1, 666.0B, zip, Category: WordPress Shortcodes