atomicsmash / twitter-feed-wordpress
Atomic Smash - Twitter Feed for WordPress
Installs: 1 741
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 5
Forks: 1
Open Issues: 1
Type:wordpress-plugin
Requires
- composer/installers: v1.0.6
- guzzlehttp/guzzle: 6.2.1
- guzzlehttp/oauth-subscriber: 0.3.*
This package is auto-updated.
Last update: 2025-02-14 20:36:41 UTC
README
Installation
To make the class available, please add the following to your composer file:
"atomicsmash/twitter-feed-wordpress" : "*",
Next, create a twitter app and generate your API access keys here.
Then add these inside your environment specific constants to your wp-config file, filling in the values as appropriate:
define('TWITTER_CONSUMER_KEY',''); define('TWITTER_CONSUMER_SECRET',''); define('TWITTER_OAUTH_TOKEN',''); define('TWITTER_OAUTH_TOKEN_SECRET','');
At the current time you can only have one twitter feed per site however this may be changed in the future.
Pulling Tweets from a Specific User
Just add a constant specifying the username:
define('TWITTER_USERNAME','');
Don't worry about adding the '@' symbol. For example
define('TWITTER_USERNAME','atomicsmash')
Using feed in theme
You can query the cached tweets simply by calling the get
method of the
twitterAPI class:
if( isset( $twitterAPI ) ){ $tweets = $twitterAPI->get([ 'results_per_page' => 4, // int 'order' => 'asc', // 'asc|desc' 'tweet_type' => 'all' // 'all|tweet|retweet|reply' ]); }
Background syncing
To sync tweets in background, schedule a cron job to run the command:
wp twitter sync_tweets
If you are using composer in your project, then your WordPress core files might be inside a subfolder. Please modify the path to reflect this. The cron job might look like this:
/usr/local/bin/wp twitter sync_tweets --path=/path/to/www.website.co.uk/wp