Home Blog Embed A LinkedIn Video Or Post In WordPress With Shortcode

Embed A LinkedIn Video Or Post In WordPress With Shortcode

0

Of all the LinkedIn LinkedIn shortcodes WordPress Shortcode 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.

■ ■ ■

While you’re here, why not connect with me.

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

The 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

As stated, because the height of the LinkedIn embed container is a variable, it must be included.

width

The width of the embed container is usually 504 pixels. If anything else, include it into the shortcode as an attribute (eg: 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 A LinkedIn Content In WordPress With Shortcode
Description: Embed A LinkedIn Video Or Post In WordPress With Shortcode.
Download: Shortcode (V0.1) | | Plugin Page

Shortt URL for this post: http://shor.tt/19iv

LEAVE A REPLY

Please enter your comment!
Please enter your name here