Skip to content
Please note that GitHub no longer supports your web browser.

We recommend upgrading to the latest Google Chrome or Firefox.

Learn more

Embedded Profile Timeline

Ben Ward edited this page Dec 11, 2017 · 1 revision

The Twitter plugin for WordPress supports embedding the latest Tweets from a Twitter account by pasting a Twitter profile URL into the WordPress post editor or by customizing a [twitter_profile] WordPress shortcode. WordPress users capable of editing themes may add a Twitter profile to a theme's widget area through the WordPress widget editor.

Embed using a Twitter profile URL

Add an embedded profile timeline to a WordPress post by copy-and-pasting a Twitter profile URL on its own line in the post content area.

Space, the final frontier

https://twitter.com/NASA

These are the voyages of our space explorers.

The Twitter plugin for WordPress extends the oEmbed functionality for Twitter profile URLs available since WordPress 4.7 with additional plugin-specific functionality. URL-based embeds pass through the plugin's shortcode handler for site-wide customization of parameters. JavaScript normally returned in an oEmbed response is enqueued through the WordPress resource manager, improving site performance while centralizing customizations.

Embed using a shortcode

The Twitter plugin for WordPress registers the twitter_profile shortcode handler to allow customization of an embedded profile timeline through a shortcode macro.

Space, the final frontier

[twitter_profile screen_name="NASA" height="400"]

These are the voyages of our space explorers.

Supported shortcode parameters

Attribute Description Example
screen_name Display Tweets from the specified Twitter username TwitterDev
width Set the maximum width of the timeline in whole pixels 500
height Set a fixed height of the timeline in whole pixels 400
limit Display a static timeline expanded to up to N Tweets. The height attribute has no effect when a limit is specified 5
chrome Toggle the display of design elements in the widget with comma-separated tokens. Accepted tokens: noheader, nofooter, noborders, noscrollbar, transparent noheader,nofooter
aria_polite Set the ARIA politeness of the timeline live region as new Tweets are added assertive
theme Set a light or dark widget background Overrides the site-wide value set through the plugin settings page dark
theme Set a light or dark widget background Overrides the site-wide value set through the plugin settings page dark
link_color Adjust the hexadecimal color of links, including hashtags and @mentions, inside each Tweet. Overrides the site-wide value set through the plugin settings page 21759b
border_color Adjust the hexadecimal color of borders between Tweets. Overrides the site-wide value set through the plugin settings page d54e21

Site-wide customization using a filter

A website may set site-wide preferences for profile timelines by acting on the associative array passed to the shortcode_atts_twitter_profile WordPress filter. Functions acting on the filter should set a decimal integer when modifying the value of the width, height, or limit key.

Example:


/**
 * Always display a timeline at a height of 400 pixels
 *
 * @param array $out        Parsed user-defined valid attributes or default attribute value
 * @param array $pairs      supported attributes and their default values
 * @param array $attributes user-defined attributes in the shortcode tag
 *
 * @return array options array with our customization applied
 */
function timeline_custom_options( $out, $pairs, $attributes )
{
  $out['height'] = 400;
  return $out;
}
add_filter( 'shortcode_atts_twitter_profile', 'timeline_custom_options', 10, 3 );
You can’t perform that action at this time.