On: 2009/06/25
Shorter URL for this page: http://ozh.in/m7

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!)

Shorter URL

Want to share or tweet this page? Please use this short URL: http://ozh.in/m7

Metastuff

This page "YOURLS WordPress (a Short URL Plugin)" was posted on 25/06/2009 at 10:15 pm
Watch this discussion : Comments RSS 2.0.

472 Blablas

  1. Andrew Merskin says:

    Rose, same here. I set it all up correctly without any luck at all. I'm getting the "Bleh…" errors.

  2. Oliver says:

    hi,
    thx for this awesome plugin. works great, but for every new post, it creates 2 short urls with the same target url. any idea?
    oliver

  3. Ozh says:

    Oliver » Never heard of that. How are the posts published? Via the regular interface? Via XMLRPC? Scheduled or instant? Give more details and file an issue there please.

  4. Martin says:

    Great plugin and I really like the YOURLS functionality.

    It would be great if the WP plugin would support creating short links when adding links with the edit post/page views.

    Or, perhaps even auto-generation of short links of all (or selected) links in a post, but that I suppose would require quite a lot more development.

  5. Ozh says:

    Martin » There is sort of auto generation. Simply add the template tag to display a short URL in your single.php and if the short URL has not been generated already, it will be on the fly at display time

  6. Martin says:

    I understand this works to create a short link to the current post. But, I would like to "replace" (external) links in the post with short links. Is that also possible using a template tag? If so, what template tag? I couldn't find it.
    Thanks!

  7. Ozh says:

    Martin » Not possible at the moment

  8. Scott says:

    Just wondering if there's going to be an option to add the category to the auto-generated message on Twitter? At present we can just get the url and title.

  9. Ozh says:

    Scott » This is planned in the next version of the plugin, which will be released errr I don't know when :)

  10. Aryan Mughal says:

    Hi,

    Is There Any Possibility That we configure multiple twitter accounts so that the post goes to all the twitter accounts

    Thanks In Advance

  11. Ozh says:

    Aryan Mughal » Twitter spam? Not going to implement something like this :)

  12. Aryan Mughal says:

    Hi,

    I dun want this feature for spamming… i work with my friend on a website who wants to update all the twitter accounts will latest news

  13. Scott says:

    Cheers for the reply Ozh! Looking forward to the next version! Keep up the good work :-)

  14. Hi there OZH!!!
    Long back i had given a request for adding up ping.fm into this plugin.

    I remember u informing me that you are working upon it and that ping.fm hasn't authorized the app from their side yet.

    Any updates on that??? :)

  15. Ozh says:

    Sujit Philipose » No. I just dropped the whole idea of doing anything with ping.fm for the rest of my life. Sorry :)

  16. OZH >> its ok… ;)
    anyways, i luv YOURLS and your plugin. Would find some alternative way to post yourls link to ping.

    Cheers :)
    Sujit

  17. Dan says:

    Any chance we will be able to enter custom URLs instead of random with this plugin?

  18. Ozh says:

    Dan » I don't understand what you mean. You don't "enter URLs" in this plugin

  19. Dan says:

    Sorry, I meant like in this image: http://yourls.org/images/admin-dashboard.gif

    Where you can enter custom short tags instead of randomly generated ones.

  20. Ozh says:

    Dan » Ho. Not sure how this would be feasible, from a user POV. How do you envision the UI of such a feature?

  21. Dan says:

    I was thinking down in the box on the right of the add/edit post/page section.

    http://www.d4nz.net/images/yourls.jpg

    You could have an input box to enter the custom short tag, if left blank it would be random?

  22. Andy says:

    Curious if anyone else was having difficulty with this plugin after upgrading to WordPress 2.9?

    It automatically tweets everything but the YOURL shortened URL. When I go to the YOURLs admin panel, no shortened URL was ever made and I have to create one and post it manually. I then delete the initial botched tweet.

    The only other change I made was to remove the "Shortlink" plugin by Sam Johnston and Rob Allen. I tried to reinstall it, but received a fatal error.

    Any feedback from others would be helpful.

  23. Ozh says:

    Andy » Nothing in 2.9 has affected how the YOURLS plugin works, except maybe if using the official WP Stats plugin, which has been fixed in latest YOURLS released yesterday

  24. Rocky says:

    I have just set up my yourls account and got it working great. I used the value applications part to my hosting company RnRGodomains and they instaled it for me. Works great and didn't have to do a thing but input login info and database login info. But I too am not able to get it to send the shorten URL. It is set up right but on my twitter account it will not post the short link. It post the message in twitter and it also puts the shortened URL in my admin page of my YOURLS. But in twitter no link for anyone to link back to my wordpress blog post from twitter. Post is in twitter though. Please help. Everything works great otherwise.

  25. Rob Parker says:

    Hi, I was wondering if it would be OK by you to create an 'own-branded' version of this plugin for my own Yourls installation? I would, of course, still maintain links back to your site.
    Thanks!

  26. Ozh says:

    Rob Parker » Sure. Please just don't distribute it as if you were the author :)

  27. Mel Reyes says:

    Andy, I'm having the same problem, the link is created, show up in custom, doesn't show up in the edit sidebox and doesn't post with the shortened link. I'm using a public api instance on api.mrte.ch

  28. Andy says:

    Apologies to Ozh, but Mel, I couldn't get the plugin to work, even after fresh installing a new, updated copy. I ended up switching over to the plugin Shorten2Ping and it is working just fine.

    Ozh, I am using the WP Stats plugin and as I mentioned, it still wasn't working even after uninstalling the plugin and reinstalling. I may give it another try if a new version comes along in the future.

  29. I am running version 1.3.3 of the plugin. I am running WordPress 2.9.1 and I have the WordPress Stats plugin (ver 1.6.1). Today's blog post said that it tweeted, but it did not. I used the re-promote and it did show in my twitter feed.

    I found that a bit odd, so figured I would checkin here to see if anyone had been having similar. And I see that it is supposed to be working fine with 2.9 and WordPress Stats. So I am confused as to what could be the issue.

  30. Garret says:

    I was wondering if you guys have thought of making yoursl truly multi user. Meaning users can sign up for an account, have their own login and can only see their stats? Or is it there and I'm just totally missing it?

  31. Ozh says:

    Garret » A future version of YOURLS will be multi user, probably

  32. Garret says:

    Ozh,

    Was wondering if you were open to getting paid for pushing forward some additions to Yourls.

    Looking for true multi user with email verification on sign-up.

    Extending stats as an aggregate per user would be nice too, enabling true reporting on stats.

    Thanks
    Garret

  33. Ozh says:

    Garret » multi user is planned as a future feature of YOURLS, so I'd feel a bit dishonest to charge anyone to code it. Although there's no ETA for it.

  34. Martyn says:

    I know 100% that this is a user (me) issue! But driving this newbie crazy so just after some help!
    I've installed YOURLS in my public_html dir in sub dir /s
    I've changed config.php (& included the /s) & tried a variety of paths in the plugin settings.
    The YOULRS function works if I navigate straight to the page & type in a url manually, but within wordpress once I post a new entry, this doesn't create a url in the YOURLS page.
    I don't even see the screenshot as above in the write page (to re-create short urls)

    Gotta be missing something :)
    Thanks in advance
    Martyn

  35. Eric says:

    Hello Ozh,

    Love YOURLS, thanks!

    I'm having some trouble with the WordPress plugin. It will generate a shorturl just fine, but the tweets never seem to make it to Twitter. Any ideas? Was there something I missed that I needd to install?

    Thanks,
    Eric

  36. Eric says:

    Hmm… Perhaps Twitter blacklisted my site, as I can't even get my tweets in my WordPress sidebar…

    Grr!

    Still, YOURLS is great! Thanks again, Ozh!

    Eric

  37. Works fine on my blog but then I'm worried cos it seems to be creating short urls for posts I didn't specify. Why is this happening?

    BTW what is the function of the Short URL auto-discovery in the options page?

    Thanks a million

  38. Ozh says:

    Udegbunam Chukwudi » It's creating short URL for all posts on the fly if you use the template tag, that's the intended behavior

  39. Well the strangest thing is that I'm not using the template tags and still it's as though it's crrating links for every visited page.

  40. Ozh says:

    Udegbunam Chukwudi » then you probably enabled the autodiscovery short url stuff that inserts the short link in the head of every post

  41. LOL. Thanks a million. That was actually the problem. I've deactivated it and the links are no longer showing up.

    Thanks man.

  42. michael says:

    I set up my own remote YOURLS install, but I can't seem to get my site to shorten a URL with it. I keep getting the "Bleh. Could not generate short URL." Error. Any ideas?

  43. Ozh says:

    michael » your blog cannot access your YOURLS setup. Wrong login/password, or web hosts cannot connect to each other (firewall etc)

  44. michael says:

    Just to double check, I just switched the plugin to using is.gd instead of my own service and received the same error. Is there some specific setting on the server I need to set?

  45. Ozh says:

    michael » The plugin uses the internal WP API to make HTTP requests. If you can, say, auto update WP or plugins, it should just work.

  46. michael says:

    Ah-ha, I have a lot of problems auto-updating WordPress, so I'll start my investigations there. Thank you very much.

  47. Mark says:

    Ozh,

    I think there is something wrong with the plugin.
    It's creating the short url OK. But it can not post to twitter.

    Just to verify if my Server IP was blocked, I installed the plugin at my personal computer. It created the short url, but did not post to twitter.

    Maybe twitter changed something. Could help us?
    Thanks.

  48. Aryan says:

    how to connect this plugin with my yourls self hosted installation though api not username and password …. and also want to say that the new version 1.4.2 is giving access anybody to admin without using username and password…

  49. Ozh says:

    Aryan » 1.4.2 precisely fixes the blank login issue that was in previous versions. Not sure what you mean with "though api not username and password". The plugin does use the API, and you need a login/pwd to connect to it.

  50. Aryan says:

    Thats what i mean …. let that if my user want to use shorten url of my domain like wlink.in than how can it paste the username and password in the yourls wordpress plugin

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>
Gravatars: Curious about the little images next to each commenter's name ? Go to Gravatar and sign for a free account
Spam: Various spam plugins may be activated. I'll put pins in a Voodoo doll if you spam me.