Tweeple Shortcode

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

Before starting, here is an overview of the Tweeple Plugin and the shortcodes it provides:

✩✩✩✩✩ () Active Installs: + Tested with: PHP Version:
Included Shortcodes:

Tweeple [tweeple_feed] Shortcode

The Tweeple shortcode is a handy tool for displaying Twitter feeds on your WordPress site. It fetches tweets from specified Twitter accounts and displays them in a structured format. The shortcode requires an ID attribute, representing the Twitter feed’s ID. If no ID is given, an error message is returned. The ID can include multiple Twitter feed IDs, separated by commas. The shortcode fetches the tweets from the specified feeds and starts outputting them. If an error occurs while fetching a feed, the error is displayed. If no errors occur, the tweets are displayed. The output is wrapped in a div with classes for styling. The final output is filtered before being returned, allowing other plugins or themes to modify it.

Shortcode: [tweeple_feed]

Parameters

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

  • id – Specifies the unique Twitter feed you want to display

Examples and Usage

Basic example – The shortcode is used to display a Twitter feed by referencing the feed ID. If the ID is not provided, an error message will be returned.

[tweeple_feed id=123 /]

Advanced examples

Displaying multiple Twitter feeds by referencing their IDs. The feeds will be displayed in the order they are listed in the shortcode.

[tweeple_feed id="123,456,789" /]

Displaying a Twitter feed with custom options. The options parameter can be used to pass additional settings to the shortcode. In this example, the ‘theme’ option is set to ‘dark’ and the ‘layout’ option is set to ‘grid’.

[tweeple_feed id=123 options="theme:dark,layout:grid" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'tweeple_feed', array( $this, 'feed_shortcode' ) );

Shortcode PHP function:

function feed_shortcode( $atts ) {

        // Check for missing feed id.
        if ( empty( $atts['id'] ) ) {
            return __( 'No Twitter feed ID given.', 'tweeple' );
        }

        $atts['id'] = str_replace( ' ', '', $atts['id'] );
        $ids = explode( ',', $atts['id'] );

        $feeds = array();

        foreach ( $ids as $id ) {
            $feeds[] = tweeple_get_feed( $id );
        }

        // Get Tweets
        $tweets = tweeple_get_tweets( $feeds );

        // Start output
        $output  = '<div class="tweeple tweeple-feed tweeple-feed-shortcode">';
        $output .= '<div class="tweeple-inner">';

        // Errror checking
        $error = '';

        foreach ( $feeds as $feed ) {
            if ( tweeple_error( $feed ) ) {
                $error = sprintf( '<p>%s</p>', tweeple_error( $feed ) );
            }
        }

        if ( ! $error ) {

            // We are a go! Display shortcode.
            ob_start();
            do_action( 'tweeple_display_shortcode', $tweets, $feed['options'], $feed['info'] );
            $output .= ob_get_clean();

        }

        $output .= '</div><!-- .tweeple-inner (end) -->';
        $output .= '</div><!-- .tweeple-feed-shortcode (end) -->';

        return apply_filters( 'tweeple_feed_shortcode', $output, $atts['id'], $feed );
    }

Code file location:

tweeple/tweeple/inc/class-tweeple.php

Conclusion

Now that you’ve learned how to embed the Tweeple Plugin shortcode, 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 *