Easy Twitter Feed Shortcodes

Below, you’ll find a detailed guide on how to add the Easy Twitter Feed Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Easy Twitter Feed Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Easy Twitter Feed Plugin and the shortcodes it provides:

Plugin Icon
Easy Twitter Feed

"Easy Twitter Feed is a dynamic WordPress plugin that effortlessly integrates your Twitter feeds into your website. Its user-friendly interface makes it simple for even beginners to use."

★★★★☆ (10) Active Installs: 3000+ Tested with: 6.3.2 PHP Version: 7.1
Included Shortcodes:
  • [timeline]
  • [follow_button]

Easy Twitter Feed [timeline] Shortcode

Easy Twitter Feeds shortcode enables you to embed your Twitter timeline on your website. It accepts parameters like username, width, height, theme, and title. If the username is provided, it displays the Twitter timeline of the given user. If not, it prompts to enter the Twitter handle. The width, height, and theme parameters adjust the display of the timeline. The title parameter customizes the heading of the timeline.

Shortcode: [timeline]

Parameters

Here is a list of all possible timeline shortcode parameters and attributes:

  • username – Represents the Twitter handle to display tweets from.
  • width – Determines the width of the Twitter feed on the page.
  • height – Sets the height of the Twitter feed on the page.
  • theme – Decides the theme of the Twitter feed, default is ‘dark’.
  • title – Sets the title displayed above the Twitter feed, default is ‘Tweets by’.

Examples and Usage

Basic example – A simple usage of the shortcode to display a Twitter timeline feed of a specific user.

[timeline username="Twitter"]

Advanced examples

Displaying a Twitter timeline feed with a specified width and height. Here, the shortcode is used to customize the size of the Twitter timeline feed.

[timeline username="Twitter" width="500" height="300"]

Displaying a Twitter timeline feed with a specific theme and custom title. This shortcode usage allows you to customize the appearance and title of the Twitter timeline feed.

[timeline username="Twitter" theme="light" title="Latest Tweets by"]

Combining all the parameters to display a fully customized Twitter timeline feed. This shortcode usage displays a Twitter timeline feed with specified width, height, theme, and title.

[timeline username="Twitter" width="500" height="300" theme="light" title="Latest Tweets by"]

PHP Function Code

In case you have difficulties debugging what causing issues with [timeline] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('timeline','etf_shortcode_func');

Shortcode PHP function:

                    function etf_shortcode_func($atts){
	extract( shortcode_atts( array(
		'username' => null,
		'width' => null,
		'height' => null,
		'theme' => 'dark',
		'title' => 'Tweets by',
	), $atts ) );
?>
<?php ob_start();?>	
<?php if (!empty($username)){ ?>
<a class="twitter-timeline" data-width="<?php echo esc_attr($width); ?>" data-height="<?php echo esc_attr($height); ?>" data-theme="<?php echo esc_attr($theme); ?>" href="https://twitter.com/<?php echo esc_attr($username); ?>"><?php echo esc_html($title); ?> <?php echo esc_html($username); ?></a> 
<?php }else{ echo '<h2>You must enter your Twitter handle in the username attribute of the shortcode.  </h2>';}
$output = ob_get_clean();return $output;
}
                    

Code file location:

easy-twitter-feeds/easy-twitter-feeds/easy-twitter-feeds.php

Easy Twitter Feed [follow_button] Shortcode

The Easy Twitter Feeds plugin shortcode enables you to add a Twitter follow button to your WordPress site. This shortcode extracts attributes like username, size, and count from your Twitter account. If a username is provided, it generates a follow button linked to the specified account. The size and count attributes adjust the display of the button. If no username is found, it prompts to enter a Twitter handle.

Shortcode: [follow_button]

Parameters

Here is a list of all possible follow_button shortcode parameters and attributes:

  • username – the Twitter handle of the account to follow
  • size – determines the size of the follow button
  • count – controls the display of the follower count

Examples and Usage

Basic example – A simple usage of the shortcode to add a follow button for a specific Twitter user.

[follow_button username="wordpress"]

With this shortcode, a Twitter follow button will be generated for the user “wordpress”. The button will be in default size and will not show the follower count.

Advanced examples

Using the shortcode to add a follow button for a specific Twitter user, with a large button size and showing the follower count.

[follow_button username="wordpress" size="large" count="true"]

In this example, the shortcode will generate a Twitter follow button for the user “wordpress”. The button will be large in size and will display the follower count.

Another advanced example is using the shortcode to add a follow button for a specific Twitter user, with a default button size but without showing the follower count.

[follow_button username="wordpress" count="false"]

In this case, the shortcode will generate a Twitter follow button for the user “wordpress”. The button will be in default size and will not display the follower count.

PHP Function Code

In case you have difficulties debugging what causing issues with [follow_button] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('follow_button','etf_shortcode_follow_func');

Shortcode PHP function:

                    function etf_shortcode_follow_func($atts){
	extract( shortcode_atts( array(
		'username' => null,
		'size' => null,
		'count' => null,
	), $atts ) );
?>	
<?php ob_start();?>	
<?php if (!empty($username)){ ?>

<a href="https://twitter.com/<?php echo esc_attr($username); ?>" class="twitter-follow-button" data-size="<?php echo esc_attr($size); ?>" data-show-count="<?php echo esc_attr($count); ?>">Follow @<?php echo esc_html($username); ?></a>

<?php }else{ echo '<h2>You must enter your Twitter handle in the username attribute of the shortcode.  </h2>';}
$output = ob_get_clean();return $output;
}
                    

Code file location:

easy-twitter-feeds/easy-twitter-feeds/easy-twitter-feeds.php

Conclusion

Now that you’ve learned how to embed the Easy Twitter Feed Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *