Warning: Creating default object from empty value in /home/planetozh/planetozh.com/blog/wp-content/plugins/paged-comments/paged-comments.php on line 31

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/planetozh/planetozh.com/blog/wp-content/plugins/paged-comments/paged-comments.php:31) in /home/planetozh/planetozh.com/blog/wp-content/plugins/yourls-wordpress-to-twitter/plugin.php on line 73

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/planetozh/planetozh.com/blog/wp-content/plugins/paged-comments/paged-comments.php:31) in /home/planetozh/planetozh.com/blog/wp-content/plugins/yourls-wordpress-to-twitter/plugin.php on line 73

Warning: Cannot modify header information - headers already sent by (output started at /home/planetozh/planetozh.com/blog/wp-content/plugins/paged-comments/paged-comments.php:31) in /home/planetozh/planetozh.com/blog/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 62

Warning: Cannot modify header information - headers already sent by (output started at /home/planetozh/planetozh.com/blog/wp-content/plugins/paged-comments/paged-comments.php:31) in /home/planetozh/planetozh.com/blog/wp-content/plugins/ozh-who-sees-ads/wp_ozh_whoseesads.php on line 630

Warning: Cannot modify header information - headers already sent by (output started at /home/planetozh/planetozh.com/blog/wp-content/plugins/paged-comments/paged-comments.php:31) in /home/planetozh/planetozh.com/blog/wp-content/plugins/ozh-who-sees-ads/wp_ozh_whoseesads.php on line 631

Warning: Cannot modify header information - headers already sent by (output started at /home/planetozh/planetozh.com/blog/wp-content/plugins/paged-comments/paged-comments.php:31) in /home/planetozh/planetozh.com/blog/wp-content/themes/planetozh/functions.php on line 172

Warning: Cannot modify header information - headers already sent by (output started at /home/planetozh/planetozh.com/blog/wp-content/plugins/paged-comments/paged-comments.php:31) in /home/planetozh/planetozh.com/blog/wp-content/themes/planetozh/functions.php on line 173
YOURLS WordPress (a Short URL Plugin) « planetOzh
On: 2009/06/25 Viewed: 58359 times
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 the plugin : yourls-wordpress-to-twitter.zip
Extract and upload to your blog, preserving directory structure.

Note: the plugin requires PHP 5 to run.

Template Tags for you theme

The plugin comes with two template tags:

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

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:

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


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

    Pages: « 1 [2] 3 4 5 6 7 8 9 10 » Show All

  1. 51
    mark beekman United States »
    said, on 21/Aug/09 at 10:51 pm # :

    here's what i found:

  2. 52
    mark beekman United States »
    replied, on 21/Aug/09 at 10:53 pm # :

    Appears code was stripped from comment:

    response action='yourls-promote_0′ object id='0′ position='1′

  3. 53
    Wolfgang Germany »
    wrote, on 23/Aug/09 at 6:49 pm # :

    There is an error in the new version 1.2. It sends out a php-warning after activating and after a click on the WP-dashboard:

    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'wp_ozh_yourls_add_dashboard_widgets' was given in /**deleted****/wp-includes/plugin.php on line 339


  4. 54
    Ozh France »
    thought, on 23/Aug/09 at 7:28 pm # :

    Wolfgang » oooops, I forgot to remove this test before committing :P Thanks for the head up, it's fixed in 1.2.1

  5. 55
    Wolfgang Germany »
    commented, on 23/Aug/09 at 8:18 pm # :

    Thank you :-)

  6. 56
    mark beekman United States »
    replied, on 23/Aug/09 at 8:55 pm # :

    Works great now. Thanks for the fix.

  7. 57
    joshnunn Australia »
    replied, on 24/Aug/09 at 6:55 am # :

    I just can't get wp_ozh_yourls_raw_url() to work for me – I get no output from it.

    This is what I have in my theme:

    1. &lt;a href=&quot;http://twitter.com/home?status= - " title="share on twitter"&gt;Share on Twitter</a>
  8. 58
    Sujit India »
    said, on 26/Aug/09 at 8:05 pm # :

    Hi there Ozh !!!
    I saw u added something about ping.fm in the plugin.
    Thanks for tht.

    Hope it would be functioning soon… ;)

  9. 59
    Ozh France »
    replied, on 26/Aug/09 at 8:45 pm # :

    Sujit » I added the code, in theory it works. Now just waiting for those retards from ping.fm (yeah, I don't like this site and it's slow as hell) to approve my application key I requested more than 10 days ago.

  10. 60
    A short URL service of our own « s... United States »
    pingback on 27/Aug/09 at 5:58 am # :

    […] that it offered per-user stats but global stats will work for now. The best part of YOURLS is a WordPress plugin from the same author. The plugin comes dangerously close to giving me the workflow I described in […]

  11. 61
    Paul OFlaherty United States »
    said, on 27/Aug/09 at 10:38 pm # :

    Thanks for an awesome plugin and script. Have been busy setting it up to working with all of our various domains and it all appears to be working smoothly.

    Thanks again.


  12. 62
    Garret United States »
    thought, on 30/Aug/09 at 1:14 am # :

    Sorry, was not clear or complete. I am using Yourls. The plugin is not creating a link there it doesn't look like no posting a tweet. How can I debug this?

    Better I hope.


  13. 63
    Ozh France »
    replied, on 30/Aug/09 at 10:05 am # :

    Garret » Use firebug and check the return of the Ajax call

  14. 64
    Garret United States »
    thought, on 30/Aug/09 at 3:39 pm # :


    Got it thanks, I think primaryly user related. Thanks again!


  15. 65
    Garret United States »
    commented, on 30/Aug/09 at 3:51 pm # :


    I do have some questions about how the search engines relate to this shortener. Both Google and Bing and indexing now, Some of the other shorteners are really starting to take this into consideration. Are you guys putting some thought into this, and are you doing anything related to this?


  16. 66
    Ozh France »
    thought, on 30/Aug/09 at 8:24 pm # :

    Garret » I don't see how indexing and URL shortener relate…

  17. 67
    Garret United States »
    wrote, on 30/Aug/09 at 9:04 pm # :

    I apologize, I have gotten very little sleep the last few days.
    The search engines are indexing Twitter much more these days. I know that some of the url shorteners are talking about incorporating 301 redirects. I would like to know if anything, what you are looking at enabling some functionality that enables good seo.

    Thanks for your patience man
    /me so friggen tired

  18. 68
    Ozh France »
    wrote, on 30/Aug/09 at 9:26 pm # :

    Garret » As far as I know *all* URL shorteners are using 301. I wouldn't use one that does 302. And of course YOURLS is using 301 too, as you can see easily if you look into the source.

  19. 69
    Sujit India »
    thought, on 30/Aug/09 at 10:50 pm # :

    Hi there… I agree !!!
    almost all the developers i know who've tried something with ping.fm have complained about their application key being accepted after a hell lot time.

    Lets cross our fingers and wait for those useless people to clear out things. :(

  20. 70
    Travis Canada »
    replied, on 02/Sep/09 at 11:51 am # :

    I'd love to see another function added to the plugin that outputs a plain text url not wrapped in an href.

    For now, I modified your plugin to do just that, creating a new function called wp_ozh_yourls_plain_url(), which only prints "$short".

    This is handy for printing the url in an input form field that people can easily click on and copy (a la YouTube's embed code form).

    Thanks. Ozh.

  21. 71
    Ozh France »
    said, on 02/Sep/09 at 12:01 pm # :

    Travis » That's what wp_ozh_yourls_raw_url() is for (not sure I updated the doc about this one)

  22. 72
    Travis Canada »
    replied, on 02/Sep/09 at 12:02 pm # :

    I guess I should have scrolled down a little further :) My bad. Thanks, Ozh!

  23. 73
    George United Kingdom »
    wrote, on 04/Sep/09 at 11:13 pm # :

    This plugin broke my site! Wouldn't let me edit posts, spent ages debugging and it turned out to be this! Deleted immediately!

  24. 74
    joshnunn Australia »
    wrote, on 05/Sep/09 at 9:35 am # :

    @George – there's a known issue with this plugin when used with twitter tools that sounds like the problem you're having. Ozh may have fixed that issue since first reported, but if he hasn't I'm sure he's on top of it.

  25. 75
    Jamie United Kingdom »
    replied, on 05/Sep/09 at 12:15 pm # :

    George, please be fair, This plugin did not break your site, If it did it would break all sites, It is most likely tha the problem was caused by your unique combination of plugins rather tha just this one. See the post above for the best place to start!

  26. 76
    Ozh France »
    wrote, on 05/Sep/09 at 12:21 pm # :

    joshnunn & George » as far as I know the issue with Twitter Tools has been fixed. And I can't do anything else valuable with dumb feedback like "it broke my site!!!".

  27. 77
    Scott United Kingdom »
    said, on 09/Sep/09 at 7:16 pm # :

    First of all – thanks for such a brilliant plugin and service (YOURLS). I set up my own service via thmm.eu, and it works like a dream for stuff published on my slightly longer-named site http://www.themusicmagazine.co.uk.

    The problem I'm having is that the plugin isn't actually publishing a URL to my Twitter feed (@tmmfeed – a new one set up just for this). I have to click "retweet" up to five times for it to publish anything, and it has never worked by just clicking publish on WordPress – despite the plugin options being ticked. Just wondering if it's anything that you've come across that I can apply a fix for, or if there's anything I can try.

    Otherwise, a brilliant job!

  28. 78
    Ozh France »
    said, on 10/Sep/09 at 11:01 am # :

    Scott » If it works "sometimes" after you click retweet, then there must be something funky on your side. Is there any error when you tweet and it doesn't work, or does it just fail silently?

  29. 79
    Scott United Kingdom »
    thought, on 10/Sep/09 at 12:50 pm # :

    Thanks for the reply!

    It just fails silently. It claims to have been a success, however nothing appears on the Twitter feed. I wouldn't even know where to start looking for a problem!

  30. 80
    kenduret United States »
    thought, on 16/Sep/09 at 9:53 am # :

    Great plugin and service… now if I could only get it to work. All is well until I click on the short url at twitter.

    The short url is not re-directing to the post. Instead I go to the short url domain and get this on the screen:

    string(78) "http://mydomain.com/where-i-should-be-redirected-to/"

    Any ideas?

  31. 81
    Ozh France »
    thought, on 16/Sep/09 at 10:04 am # :

    kenduret » Yes. Use latest version.

  32. 82
    kenduret United States »
    said, on 16/Sep/09 at 10:41 am # :

    Doh!- No wonder you're famous and I'm not!

    Working beautifully.

  33. 83
    Rodney United States »
    wrote, on 17/Sep/09 at 6:18 pm # :

    I think I found a bug:

    If you're using a remote/private yourls install and you enter your username/password wrong on the plugin setup page. Shorten urls for pages turned on.

    Then, if you go to edit a wordpress page, it tries to generate a shorturl for that page. Since the username/password was incorrect, it shows "invalid username/password" for the yourls_shorturl value.

    The problem is that there seems to be no way to fix this error and regenerate a shorturl for the page if you fix the username/password in the plugin settings.

    I tried deleting the custom field, but it doesn't seem to regenerate the short url if I go back and edit the page.

  34. 84
    Ozh France »
    thought, on 17/Sep/09 at 6:54 pm # :

    Rodney » The problem is that you're changing the login/pwd in WP's options, but the old values are still cached until next cache refresh

  35. 85
    Rodney United States »
    replied, on 17/Sep/09 at 6:59 pm # :

    Ahh, cache. I didn't think of that. I just went back to edit the page and Viola, it worked just fine. Thanks (and thanks for the great script)!

  36. 86
    Rodney United States »
    commented, on 17/Sep/09 at 7:17 pm # :

    I'm trying to use yours>twitter with the wpgreetbox plugin so that it includes the shorturl generated by yourls when it allows people to share a post via twitter.

    In the last template tag example above, can you tell me how to pass the echo parameter to the tag?

    I read the codex page here:

    And tried:


    But neither seemed to work.

  37. 87
    Ozh France »
    thought, on 17/Sep/09 at 8:55 pm # :

    Rodney » Sorry I don't know the wpgreetbox plugin. You should contact the author of this plugin and ask if there's a way to pass a parameter. Even better, ask him to add a hook so that other plugins or themes can modify what his plugin display.

  38. 88
    mark beekman United States »
    thought, on 22/Sep/09 at 7:36 pm # :

    Ozh, any idea when you'll be releasing the next version? The new stats functionality, graphs and demo page look amazing.

    Thanks for the great work on this.

  39. 89
    Ozh France »
    replied, on 22/Sep/09 at 9:14 pm # :

    mark beekman » Everything is done, mostly, I just want to make sure the installer / upgrader is robust enough. I'm waiting for some feedback from beta testers. Hopefully this week-end, or maybe next week.

  40. 90
    Garret United States »
    commented, on 22/Sep/09 at 9:23 pm # :

    If you need any more beta testers I have some bandwidth for that right now.


  41. 91
    Ozh France »
    thought, on 22/Sep/09 at 9:38 pm # :

    Garret » it's not really about bandwidth, it's more about being able to provide consistent feedback :) Thanks for the suggestion anyway, I'm waiting for the first batch of testers' feedback to check whether I was really off or not, and then I'll advise.

  42. 92
    Garret United States »
    thought, on 22/Sep/09 at 9:45 pm # :

    Ozh, I meant bandwidth as in bandwidth = personal time. But I understand, just let me know if I can help.


  43. 93
    Andrew Merskin United States »
    replied, on 30/Sep/09 at 12:10 am # :

    I'm also getting the blasted "Bleh .. can't post to Twitter .. it's 'down'" stuff. Twitter login is correct, checked three times. Running WP2.8.4 and YOURLS 1.3.1.

    Here is my XML response from Firebug:

    Any help would be greatly appreciated. I have been trying to get my posts to Twitter for weeks without any luck with other plugins, and this one as well. I was using Tweet Suite before this and suddenly TinyURL stopped working… post titles went to Twitter without links or anything.


  44. 94
    Sebi Germany »
    replied, on 04/Oct/09 at 3:48 pm # :

    Hello Ozh ;)
    Your plugin is really cool stuff. But I have one big wish: Is it possible to implement a Dashboard Widget which allows me to post manually to my Twitter-account. I often want to publish a link to other interesting sites and it would be very helpful if I could do this from my Dashboard and with my own shortening-url.

  45. 95
    Ozh France »
    thought, on 05/Oct/09 at 8:32 am # :

    Sebi » At the moment the best way to do so is shorten a link with the bookmarklet and use the Quick Share box. Not sure I'll implement this in the plugin because that's a totally different concept (twitter client vs bridge between YOURLS and the blog). Will think about it though.

  46. 96
    Sebi Germany »
    commented, on 05/Oct/09 at 11:16 am # :

    Well I think this Plugin is already a Twitter Client due to its ability to post to Twitter.
    The funcionality I suggested would enhance the helpfulness for every blogger because it allows to not only use Twitter as a timeline of the blogs content, but to really use Twitter as an extension to the wordpress-blog. So one could easily use Twitter for content-related short messages with the same specific Link-URL-Synthax as it is used by tweeting the blogs content. So it's about corporate identity ;) Think about it =)

  47. 97
    Seth Long United States »
    thought, on 07/Oct/09 at 2:17 am # :

    Ozh – Love the plugin and YOURLS. We run WPMU and it would be extremely useful to us if the plugin supported MU. With the current version, we need to provide setup instructions for our users, most of whom aren't technically-minded. I would like to pre-set and hide the short URL service info, and just pre-set the rest of the preferences, to avoid user confusion and to increase usage of the plugin.

    Thanks for considering this. I'm looking forward to v1.4.

  48. 98
    Andy United States »
    said, on 07/Oct/09 at 6:21 am # :

    Have you considered some implementation of OAuth for this plugin?

    I know the reason I use my own shortening is that people can trust me and my links. However, since so many spambots on Twitter have posts that state "sent from API" people get a little nervous about posts that include that.

    It would be great if the post said "sent from Yourls" or something like that instead. I don't know what is involved to implement this, but I think it would help immensely.

    Thanks for your time!

  49. 99
    Ozh France »
    commented, on 07/Oct/09 at 8:09 pm # :

    Andy » I have considered and won't. Please see issue 64: http://code.google.com/p/yourls/issues/detail?id=64

  50. 100
    Rose Nepal »
    replied, on 18/Oct/09 at 11:26 pm # :

    This is not working for me. I enabled it. looks fine, added login and api keys but still nothing on twitter. And other plugins aren't working either.

Pages: « 1 [2] 3 4 5 6 7 8 9 10 » Show All

Leave a Reply

Comment Guidelines or Die

  • HTML: You can use these tags: <a href=""> <em> <i> <b> <strong> <blockquote>
  • Posting code: Post raw code (no <> &lt; etc) within appropriate tags : [php][/php], [css][/css], [html][/html], [js][/js], [sql][/sql], [xml][/xml], or generic [code][code]
  • Gravatars: Curious about the little images next to each commenter's name ? Go to Gravatar.
  • Spam: Various spam plugins on patrol. I'll put pins in a Voodoo doll if you spam me.
  • I will mark as Spam test comments, all comments with SEO names (ie "My Cool Online Shop" instead of "Joe") or containing forum-like signatures.