YOURLS WordPress (a Short URL Plugin)

yourls-logoYOURLS (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.

The latest version of the plugin does not support Twitter any longer. I have not enough free time to maintain that part, due to the regular changes from Twitter on their authentication process. If you want to auto tweet your posts, use a plugin for that.
This plugin is not maintained any longer. It's still working probably fine (here on this blog for instance) but I'm not investing any more time on it. No support or anything.

Download

Download the plugin : yourls-wordpress-to-twitter.zip
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!)

472 comments

  1. David

    Unable to tweet posts! Error reported as "Read Only Application" even though I have set Twitter App to 'Read and Write'. So what am I doing wrong please?

  2. dig

    Same Problem as in #398 described. Need a fix, too.

  3. Joe

    Tried setting up three applications and everytime in the WordPress configuration the error I get is "Could not authenticate with OAuth.". I click the "Sign in with Twitter" button and then select "Authorize App" on twitters website, and nothing changes. I've checked in twitter which connected apps I have and the app is connected.

    Not sure if this is related or not but I did upgrade to 1.5.1. reading the svn changelog it doesn't seem that it would cause this but something is.

    Any ideas? I don't want to post the link to the site publicly but will gladly give you the link via email or on twitter.

    Thanks, Joe

  4. Sundar

    @David [401], I had the same problem but I fixed it now. When we are creating the application on twitter,we are asked to get the Access token before that make sure you have choose the read and write option on Access level if not go to settings and application type – access to read and write. Now you can create the access token and insert the details in to the WP settings it works fine.

  5. Travis

    Getting an error when tweeting from the edit post page. "Could not authenticate you."

    The website is a football blog and was recently updated to wordpress 3, currently 3.2.1/ I only noticed this error after the updates.

  6. Sujit

    Hi there, :)

    need your help. My yourls is working perfectly. But i want to achive a small thing which I don't know how to do it.

    I've got two domains. longdomain.com and short.com
    with the help of short.com/xxxx people are getting redirected to longdomain.com/2011/09/blahblabla/. That is cool and fine.

    But I want if someone visit short.com then they are redirected to longdomain.com without disturbing the yourls script functionality.

    I know it's possbile through htaccess file but don't know how to do it without breaking yourls redirectional functions.

  7. Ozh

    Sujit » why resort to a complicated .htaccess rule when a simple header('new location'); in an index.php is enough?

  8. Sujit

    Cool, i guess i'll do what you mentioned.
    Thanks for the help :D

    I guess, it will resolve my prob :)

  9. Ozh

    Sujit » side note: this is the page of the *WordPress plugin*. Not where to seek assistance for YOURLS.

  10. Oz

    Hi,
    excellent service and plugin!
    But i'm having some problems. Sometimes the plugin tweets the content with the shortened URL sometimes it doesn't, even though the shortened URL is generated. I've tried to disable some other plugins (like intensedebate), but it didn't solved the problem.
    Any thoughts?
    Regards,

  11. Ma Wenjian

    I come from China.In my country,Twitter is blocked,so an edition without twitter function is welcomed!I simplely need a plugin that can short my URL.

  12. Ozh

    Ma Wenjian » Read this very page please.

  13. Francesco

    Hi, i noticed you make an update yesterday. But no changelog. If plugin works well must i do this update (for security reason) or can i use the old one for some times… without worry?

  14. Ozh

    Francesco » there's always a changelog. Check the readme & plugin source if interested. Anyway, whenever something you use offers an update, update. Period. There's never a valid reason not to update.

  15. Richard Hay

    Ozh,

    Anyway to get a previous version – something before these last two updates.

    For some reason my posts are getting two shortened URLS from the plugin since these recent upgrades. Therefore, I am getting a lot of dulicates that read 0.

    It appears the first URL is assigned when the post is published and then it gets a second one when it goes out on Twitter.

    Confusing I know but I would like to get back to something stable for now.

    Thanks.

    Rich

  16. Alex Mielus

    I am using this plugin since I discovered and used your excelent app: YOURLS. I have a private url shortner and it works great on most of the WP blogs that I have … but not on some.

    On 4-5 WP based sites the config that I already setup just vanishes after I publish a post and it needs to be setup once again.
    What can I do?

    Thanks.

  17. Alex Alouit

    Hi,
    Wonderful plugin, but, recently, I have this error "Timestamp out of bounds".
    http://code.google.com/p/twitter-api/issues/detail?id=2017 (Same problem? "Your timestamp is in milliseconds instead of seconds. The OAuth standard asks for the value in seconds.")

    Best regards,

  18. Lars

    Same as #417 here

  19. AQ

    Hello, Could you please create step-by-step instructions for customising WordPress plugin(like here http://yourls.org/3o), i can't customising Access Token* and Access Token Secret* and can't login to the Twitter. He is show me PIN field, but i don't know where i can found this value. Thank you for your help!

  20. Mike

    Having trouble finding the callback URL for the plugin. Can that be shared?

    Thanks!

  21. Cristian

    It is any way to use multiple twitter user names with YOURLS installed in a wordpres multisite with domain mapping? I want to use a diffrent twitter account for each domain name that is mapped to the network.

  22. Abyss

    Hi, I'm using WP 3.2.1, BP 1.5.1 and YOURLS plugin 1.5.3. I've registered my Twitter app, I have my keys and tokens and my Callback URL is my blog's frontpage. But when I try to save changes to YOURLS configuration I get a message saying it can't authenticate me. I click on the "login with twitter" button, it displays my Twitter app correctly but then I get stuck with this error: "An error occurred while trying to retrieve your Twitter username. Please try again."

    Any help would be appreciated.
    Thanks !

  23. Mike

    Same as 422. Have tried several different ways and still not working. Any help would be appreciated.

    Thanks!

  24. Hernandez

    I having trouble to authenticate with OAuth, it ask me to sign in into Twitter.

    But when I click it it shows
    "Next, return to Apps For An and enter this PIN to complete the authorization process: 0123456"

    Can you help?

  25. Alex

    Since WP3.3 a Post which is posted with the iOS WordPress App. does not trigger a short URL and no tweet. If I read the Post in the backend, the URL is generated and I can manuell tweet it.
    But not automatically by using the WP-App.

  26. Ed

    This plugin stopped integrating with Twitter recently. Was this a Twitter API change or a plugin change? Either way it will not authenticate to Twitter any more.

  27. Travis

    I am having the same issue on a new install today, keeps sending me to an authorization pin after connecting with twitter in the plugin settings.

    None of my older installs gave experienced any problems.

  28. Pgrytdal

    Hello!

    I was wondering if you could add "Tweet new page" as a feature, like in the WP to Twitter plugin… I prefer your plugin over WP to Twitter, BC yours is easier to use, but I like his Tweet new Page function.

    Thanks!

  29. Casregime

    I've got yourls working in a sub-domain(even tho I can't get rid of www) and have a wordpress in another sub-domain. Now I can't point to the config file I've tried all kinda paths but it's a nogo. Is it a sub-domain issue? also the "in this help screen" popup dosn't show anything

  30. Jota

    Hi, works fine, but when trying to publish to twitter i get error "Status contains malware" from post inside WordPress, please help ! :(

    Promote this Entrada on @wtitter:

    Status contains malware

  31. Gav

    I can't find the config file inside the wordpress plugin folder. please advise.

  32. Renee

    Will there be a new version which is compatible with WP 3.3 (and up)?
    The current version does nothing with posts created via the iOS app or Quickpress.

    /Renee

  33. lastguru

    Do you plan to make the plugin support passwordlessAPI?

  34. Ozh

    lastguru » nice idea, I wonder why I never thought about this myself. I'll keep that in mind when I work on that plugin again

  35. Nerdvana

    In some cases of pre-posting, I would like to prevent an entry from tweeting. Is there a way to do this w/o disabling YOURLS plugin?

  36. Nick

    It works like a charm, but just shows the title and short url.

    I would like to have it fill it up to 140 characters with the post text, not just the title.

    Is this possible ?

    As "tweet message" I use %T – %U
    with the "new post published: generete short url" marked.

    thanks,

    Nick

    here's a link to the site
    http://www.fortherestless.com/login/newz
    and the twitter page twitter.com/fortherestless_

  37. Thias Esseboom

    Hi Ozh,

    I created the Twitter App like I should, it all worked fine until I posted 1 post on Twitter. Now it says it can't authenticate me anymore. I tried to reset all the codes, but that didn't work. (Yes I changed them in de plugin too).

    Can you help? Is it twitter just bitching around or is it my server bitching around?

    Greetings,

    Thias

  38. DJQuad

    I'm having the same problem.. "Could not authenticate with OAuth."

  39. SK

    I'm having the same issue as the last two commenters — with one twist. When I log into Twitter and grant access, I now get a PIN from Twitter that I'm supposed to put somewhere…. but where?
    Thanks, this is a great plugin!

  40. Isaac

    I had to reset my plugin settings.
    For some reason, when I click the "Save Changes" button, it now redirects me to the main site, instead of saving the settings.
    Any ideas?
    Thanks!

  41. sfbay

    Hi, same as 439. Use YouRLS religiously with my WordPress installation but lack of automatic generation is getting cumbersome. Any insight would be appreciated. Thanks!

  42. AndyP

    I have the same problem as Isaac commenting at 440. Saving the settings doesn't appear to save anything and redirects me to my homepage. Might be a clash with security plugins I suppose? In any case, I can't use the Yourls Worpdress plugin at the moment :-(

  43. Kent

    Great product! only thing is when i use my wordpress ios app my posts do not go 2 twitter. Any idea why?

  44. Ian D

    Hi folks,

    although I am using the correct path to the files and the correct username and password, it still says incorrect username and password.

    Getting really frustrated and I can't see the issue.

    any help greatly welcome.

    cheers,

    ian

  45. Blake

    I having problems authenticating with Twitter. It was working all day until I tried to tweet a post and the Tweet button didn't show up. All it gives me is the following.

    Logged on Twitter as @ ( followers)

  46. Kaiser

    I guess you can update the last paragraph in the article with the following line:

    1. add_filter( 'ozh_yourls_notice', '__return_false' );
  47. Roberto

    How can I obtain a yourls-api? I cant understand! Thanks!

  48. Ali Hussain

    Hi Ozh,
    I have been a user of YOURLs for a long time and have been using it on quite a few blogs (over 100+) Thanks mate.

    I now see/face an issue where i dont see the "retweet/repost" this link.

    Can you/anyone help?
    Thanks

  49. Fawwad

    What is the call-back URL?

  50. somnulescu

    I have the same problem as Blake, the plugin doesn't authenticate.

    I get " Logged on Twitter as @ ( followers) " the @ links to twitter.com

    Plus, I don't have a "app type Browser" anywhere in my twitter app settings.

Leave a Reply

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