I have a shortcode in my functions.php which runs a query on a category. I want to have a twitter feed on this particular page.

I have a javscript option working on my page for twitter right now but it doesn't look good and will take way to long to edit the javascript ( in minified format ) to make it look good, so I thought I would use a plugin.

I installed one and it looks good but I need to call it in a very specific spot within the shortocode. I noticed as is, it calls the widget at the top of my page from within the shortcode which breaks the layout. I did some reading and it looks like using the_widget() would allow me to call it where I want and it did put text in the right spot. Problem was instead of putting my tweets, it put an error message. I figured that If I use the_widget with the classname of the widget as shown on this page that it would work


for example. The twitter widget I downloaded is called "simple twitter tweets" and I figured that I could do


and it would work. I was wrong. PI_SimpleTwitterTweets is the classname of the widget. Am I on the right track and just missing something?

1 Answer 1


The second parameter of this function (the_widget) is an array with some arguments that defines what are the variables of this instance of the Widget, when you are outside of a Sidebar "loop", you have to pass those manually, instead of getting them from the database.

I've found the GitHub Repo for this plugin, and the arguments are in the link (AshleySheinwald/Simple-Twitter-Tweets/simple-twitter-tweets.php#L112-L138), and below:


//Set up some default widget settings.
$defaults = array(
      'title'               => __('Recent Tweets', 'pi-tweet')
    , 'name'                => __('iPlanetUK', 'pi-tweet')
    , 'numTweets'           => __(4, 'pi-tweet') // How many to display
    , 'cacheTime'           => __(5, 'pi-tweet') // Time in minutes between updates
    , 'consumerKey'         => __('xxxxxxxxxxxx', 'pi-tweet') // Consumer key
    , 'consumerSecret'      => __('xxxxxxxxxxxx', 'pi-tweet') // Consumer secret
    , 'accessToken'         => __('xxxxxxxxxxxx', 'pi-tweet') // Access token
    , 'accessTokenSecret'   => __('xxxxxxxxxxxx', 'pi-tweet') // Access token secret
    , 'exclude_replies'     => true
    , 'twitterFollow'       => false
    , 'dataShowCount'       => false
    , 'dataShowScreenName'  => false
    , 'dataLang'            => __('en', 'pi-tweet') // Language reference
    // Time
    , 'timeRef'             => false // false = use old full hour ref, true if selected will use hour ref as h (twitter style)
    , 'timeAgo'             => true // true = show ago, false will turn it off
    // Intents
    , 'twitterIntents'      => false // true = Default: show Twitter Intents
    , 'twitterIntentsText'  => false // false = Default: Show text - activate to turn off text display and use icons only
    , 'intentColor'         => "#999999" // Default colour, light grey
    // Avatar
    , 'showAvatar'          => false // Show the avatar ?
    , 'roundCorners'        => false // Do we want rounded corners
    , 'avatarSize'          => "" // what size should it be - defaults to 48px

Check what are the values which are needed for each of these settings and then the widget will be printed correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.