YOURLS (Your Own URL Shortener) is a URL shortener, like TinyURL, except it's all GPL and you can run it on your own server, publicly or for your own use only. It was made by Lester Chan and myself. Learn more about YOURLS.
This plugin, YOURLS: WordPress to Twitter, is the bridge between YOURLS and your blog: when you publish a post or a page, it will use your own YOURLS install, either hosted on the same webserver, or another server, to create a short URL for your post.
Download
Extract and upload to your blog, preserving directory structure.
Enjoy.
Note: the plugin requires PHP 5 to run.
Template Tags for you theme
The plugin comes with two template tags:
wp_ozh_yourls_url()
Will echo a HTML link with short URL (will generate it on the fly if needed) for the current post.
Example output:
<a href="http://ozh.in/j5" rel="nofollow alternate shorter" title="short URL">http://ozh.in/j5</a>
Suggested use: in the loop, in single.php, in page.php
wp_ozh_yourls_head_linkrel()
Will output a <link/> in <head> for the current post (see revcanonical.appspot.com and shorturl.appjet.net for more info)
Example output:
<link rel="alternate short shorter shorturl" href="http://ozh.in/j5" />\n
Note that WordPress echoes this <link> out of the box so you mostly won't need this one.
You can also use two other functions in your code and plugins:
wp_ozh_yourls_raw_url()
Will return (or echo if you pass true to it) the short URL, with no HTML tag or anything else. Just the raw URL.
wp_ozh_yourls_geturl( $id )
Will return (and generate on the fly if necessary) the short URL for post with id $id
Easy custom keyword
If you want your post to have a custom short URL instead of the random/sequential generated one, when you write a new post add a new custom field to it (button: "Add Custom Field") with name "yourls-keyword" and your custom keyword as a value.
Filters all over the place
If you're a coder and want to interact with the plugin, there are a lot of filters for you to do so. Just read the source and look for what you need (and if you cannot find what you need because you'd like another filter somewhere else, please tell me!)
Shorter URL
Want to share or tweet this page? Please use this short URL: http://ozh.in/m7
Aleksey » Why on Earth would you do this?? Just publish, and then you have the Shorturl button or the YOURLS metabox.
This way I have to uncheck auto-posting to twitter as the tweet sent right after publishing will contain generated URL like http://mydomain/URL/a1, instead of one based on keywords I need… Using your way, I'll need to publish the post (with wp's URL) then manage custom URL down in meta section, update the post and send the tweet manually from yourls' box on the right of the editing page.
It would be perfect to have an opportunity to set custom URL in advance, so that the tweet with it be sent right when you hit 'publish' button.
Maybe I'm missing something? Please excuse me then and give some hint on where's the truth's hiding :)
Aleksey » Indeed there's a much easier way. Wait 15 minutes till the new version of the plugin shows up in the repository, update your plugin, and publish a new post with a custom field named "yourls-keyword" in which you will put the custom keyword you'd like to use for your short URL. BTW, just added this without testing, so tell me if that works as expected :)
Ozh >> Thanks for awesome support! Never have faced anything this fast…
Just updated plugin, but unfortunately there's no such custom field you mentioned…
http://twitpic.com/2guiyw – just a proofpic
Alexey » of course not, how could the plugin guess what keyword you want? Write a new post and *create* a custom field (button "Add custom field").
Hmm… But custom fields are to be from the dropbox and ther e's no such entry as "yourls-keyword" to assign the value I need. See the pic again pls. Oh, and sorry for being noob to wp =(
Oh, what a mess I just wrote. I just found out what you've ment. Sorry… Going to try it now.
Finally, it does exactly what is needed. THANKS. You can put "The Best and The Fastest support of 2010 and ever" on top of this site! Great ;)
The custom keyword value is not working for me, anyone else having this issue?
I have added the custom field yourls-keyword but it doesn't use it for anything. I have updated to the most recent version of the plugin.
Brad, try it with the underscore like other key-words. I don't remember for sure but the plugin is 100% working
Thanks,
it did work using yourls_keyword, I would change you info above for others.
Brad Zimmerman » Just pushed a plugin update that works with 'yourls_keyword' and 'yourls-keyword' to avoid confusion
Hi. I've got the following problem when I try to connect my blog with Twitter.
Here it is:
Woah there!
This page is no longer valid. It looks like someone already used the token information you provided. Please return to the site that sent you to this page and try again … it was probably an honest mistake.
And I don't know why it happens :/ And I don't use the consumer keys in another plugin.
Thanks
Jorgicio » Bad plugin configuration
The plugin is very good working, but with the latest releases, I miss the re-twitter function for pages. How can I re-avtivate this?
Thank you
Ozh:
I don't think that may be a bad configuration… I put all my information correctly and I still have this error :/
Jorgicio: Press the "Reset Consumer Key/Secret" button for the application you created @ http://twitter.com/apps for a new set of numbers while logged into you Twitter account. Copy these to YOURLS plugin. This should fix your issue.
Great job Ozh! Thanks! One slight problem we're having. The plugin is creating a short URL for blog posts that have previously been posted. It is not posting these to Twitter, just creating a short URL for these posts, some which were posted months ago. It would appear that these posts did not have a short URL previously, since their Original URLs are not duplicated in the database.
Disabled all plugins except YOURLS and it still creates a URL for old posts, approaching 400 since we upgraded yesterday. There has to be a trigger to this, but I have not isolate what it is. Any thoughts?
AGb » Normal behavior. Short URLs are created on the fly to be included in the <head> section, in place of the wp.me link
AGb: I tried this and it still doesn't work. And I don't know why.
Thanks.
Hey, folks!
I solved the problem!
I had activated the plugin "Twitconnect", so I deactivated it, then I reactivate YOURLS WordPress to Twitter, configurated it and it works!
Then I reactivate Twitconnect and all is going on!
Thanks.
I installed this plugin and WordPress stopped working. The website looks OK, but when I log in, I see the panel on the left but that's it. The rest of the interface is just blank, nothingness. Not good.
Ha ha! WordPress 3.0 or higher is required. If you have this problem, delete the plugin folder at /wp-content/plugins and all will be OK again.
Chris Edes » No. If you have this problem, UPGRADE.
Hey guys –
Just updated to the latest version of plugin thanks to Twitter changes. When I put in my keys and click the "sign in with twitter" button, it takes me to Twitter where I authorize the app. But then when I continue it takes me to the home page of my blog with the oauth token like this:
http://myblogurl.com/?oauth_token=tokennumbersetc
…and the Twitter connection isn't actually happening. Any ideas?
Thanks!
Having encounter the error most recently after upgrading WordPress 3.0 .. Just installed the update Yourls 1.4.4 .. and still getting error; any help?
Please configure YOURLS – WordPress to Twitter settings now; YOURLS – WordPress to Twitter configuration incomplete.
It has to do with my Twitter settings .. I have entered in correct Twitter Consumer Key & Twitter Consumer Secret .. but still not working ..
Any suggestions?
Thanks
One additional point on my problem…I host my URL shortener on a different domain than my blog. Does that matter when setting up the Twitter connection?
Is it possible to add the ability to schedule multiple tweets in an upcoming release of the plugin? This would allow me to schedule tweets using the twitter app integration.
Pat OBrien » I'd rather have the other way round: a tweet scheduler plugin into which my plugin could hook. I don't think I'll add such a feature to my plugin, it's just too far from the initial purpose
I upgraded from WP 2.9.x to WP 3.01, then I reinstalled the plugin and configured it again
when I click on "sign in with twitter" I can succesfully log in on twitter website, AUTHORISE the app, but then I go back to my domain and get a "not enough permissions" error :-/
the URL is similar to this:
/wp-admin/admin.php?page=tweetable_install&installing=1&oauth=1&oauth_token=[…]
any help?
please ignore my previous post.. it is obvious that I used the wrong App i set up on Twitter.com (the one I created for tweetable plugin)
sorry!
Anyway I have the same problem as Andrew, in a previous unanswered message:
andrew United States »
commented, on 08/Sep/10 at 7:11 pm # :
Hey guys –
Just updated to the latest version of plugin thanks to Twitter changes. When I put in my keys and click the “sign in with twitter” button, it takes me to Twitter where I authorize the app. But then when I continue it takes me to the home page of my blog with the oauth token like this:
http://myblogurl.com/?oauth_token=tokennumbersetc
…and the Twitter connection isn’t actually happening. Any ideas?
Thanks!
Hey there,
Love this plugin except it is not creating the URL. Tried with all third party apps (have it set up now with bit.ly API) and it will tweet the post but not include the URL.
My Tweet Message template was custom, but I tried with this default and it still does not work: Just posted: %T %U
In the post screen YOURLs area, I get the message, "Bleh. The URL shortening service you configured could not be reached as of now. This might be a temporary problem, please try again later!"
This has been going on for days.
Thanks in advance for any suggestions you may have.
-Matt
Don't mean to be a pest here, but I miss my automatic twitter posting. Here's my problem again. Any support, please?
::
Just updated to the latest version of plugin thanks to Twitter changes. When I put in my keys and click the “sign in with twitter” button, it takes me to Twitter where I authorize the app. But then when I continue it takes me to the home page of my blog with the oauth token like this:
http://myblogurl.com/?oauth_token=tokennumbersetc
…and the Twitter connection isn’t actually happening. Any ideas?
Andrew » conflicting plugin… bad configuration… dunno.
ozh – I'm using YOURLS 1.4. Do I need to update it to get it to work with the plugin?
andrew » Don't know. I don't test old versions. I'd say probably not, but no guarantee.
Hi all,
I seem to be experiencing the same problem as Andrew and Fabrizio. I'm using Version 1.4.4 but no matter what I do I can't complete the Twitter configuration. It redirects back to my blog when I click "Allow" but the Twitter settings always remain incomplete with a "Could not authenticate you" message above the "Sign in with Twitter" button. I've closed/reopened the browser, cleared cache and cookies, reset Twitter keys, reinstalled the plug-in, and nothing seems to work. What am I doing wrong here?
Any help would be appreciated!
Thanks!
-Matt
Matthew Cupka » deactivate the other plugins that have to do with Twitter.
Oh well – deactivated and deleted all plugins and even changed theme to get away from the one that had twitter built in and the URL is still not shortened. The post to twitter works, but no URL…bummer.
"Hey there,
Love this plugin except it is not creating the URL. Tried with all third party apps (have it set up now with bit.ly API) and it will tweet the post but not include the URL.
My Tweet Message template was custom, but I tried with this default and it still does not work: Just posted: %T %U
In the post screen YOURLs area, I get the message, “Bleh. The URL shortening service you configured could not be reached as of now. This might be a temporary problem, please try again later!”
This has been going on for days.
Thanks in advance for any suggestions you may have.
-Matt"
I completely deleted all my other plugins related to Twitter.
If I host my YOURLS on a different domain name, should the domain I provide to Twitter for the app be my blog our that of the YOURLS instance?
Matt Mansfield » then it looks like you simply misconfigured the plugin and it cannot contact the shortener… Try setting it on same server and on remote.
What could be the problem here?
After registering with Twitter and inserting the proper keys, the 'Sign in with Twitter' button appears. After clicking 'Sign in..' it fails with this error:
Fatal error: Cannot redeclare class OAuthException in /home/dbdotcom/public_html/wp-content/plugins/yourls-wordpress-to-twitter/inc/oauth_lib/OAuth.php on line 8
Any ideas?
Dave Bonds » I think I'm going to make a plugin that will respond this to every single comments on this page: "conflicting plugin".
Ozh – so if I turned off every other plugin then you think yours would start working again?
Thanks Ozh. I've only got 9 other active plugins, none of which use OAuth, so I'm not sure what would be conflicting.
Turns out I just commented out lines 6-8:
in OAuth.php and it's working fine.
Not really sure if those lines are necessary?
Awesome plugin though! Thanks!
Greetings. On September 1 the WordPress auto-posting function to Twitter stopped working. The YOURLs URLs are still forming properly and I can copy and paste to Twitter, but the edit post fields stopped working, even though they give a success message. Many thanks.
Robert Mann » version of the plugin?
Version is 1.3.3. Thanks
Robert Mann » Thought so. How about you update?