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. 151
    Aryan Pakistan »
    wrote, on 11/Mar/10 at 9:13 pm # :

    /** Private means protected with login/pass as defined below. Set to false for public usage. */
    define('YOURLS_PRIVATE', false);

    Look at this ….

    if i set it to true no one can see stats of its shorten url…. and if it is false than anyone can access the admin panel
    or if i change the path of my admin folder

    my yourls to twitter plugin stops working

    Need Your help in this badly

  2. 152
    Ozh France »
    commented, on 11/Mar/10 at 9:49 pm # :

    Aryan » http://yourls.org/#Config see Optional settings

  3. 153
    Aryan Pakistan »
    wrote, on 12/Mar/10 at 11:19 am # :

    you are not getting me … i want that people can see stat and able to use my website shortening service with yourls plugin but on the other hand admin must be protected

  4. 154
    Ozh France »
    commented, on 12/Mar/10 at 8:17 pm # :

    Aryan » I think I am exactly understanding what you want. Private install (password protected admin) *but* public stats and public API. Please re-read my replies and YOURLS doc.

  5. 155
    Aryan Pakistan »
    thought, on 12/Mar/10 at 9:42 pm # :

    Can we have a private chat so i can explain you the whole think so we can sort my problem out ;)

  6. 156
    Aryan Pakistan »
    replied, on 12/Mar/10 at 11:01 pm # :

    or you can send me a config.php file which suits my need

  7. 157
    Desde.boxes Spain »
    replied, on 16/Mar/10 at 6:14 pm # :

    Hello Ozh.

    I have the same issue than Mark (#147). All things appears as OK, but plugin doesn't publish on twitter.

    Plugin creates short url OK, doesn't appear any error, but it doesn't post on twitter. New url appears on yourls installation, so wordpress->yourls works OK. Of course, I check three times user and password, and all is Ok.

    I can't see any errors in all logs I saw. Can you help us?

    Thanks in advance.

  8. 158
    Doug Smith United States »
    thought, on 17/Mar/10 at 7:01 pm # :

    Thanks so much for your work on YOURLS and the WordPress plugin!

    I have a quick question. Is there a way I could force the WordPress plugin to generate short URLs in the form of http://domain.com/POST-ID? This would have the advantage of my post URLs still working with a simple .htaccess rule if I stopped using YOURLS for some reason in the future.

  9. 159
    Ozh France »
    commented, on 17/Mar/10 at 8:29 pm # :

    Doug Smith » as of now, it's not possible. This said, in a future version I'll add hooks into the plugin, and it would then be doable to do what you want with a simple companion plugin

  10. 160
    Desde.boxes Spain »
    said, on 18/Mar/10 at 4:31 am # :

    Hello again!

    I thank you for the good work. Really it's fantastic.

    I still with same error, but now I looked for answers.

    I tried another hosting, another blog and the problem isn't solved. Then I came here and I saw most pages of "Blablas", and deactivate wordpress stats plugin. The issue continues.

    The short url is generated, so WP->YOURLS works. The communication WP->Twitter is where all fails.

    I looked for in twitter.php, and I found the pluggin only shows an error if the response to twitter contains something like "error" word. I'm not sure with this, I'm not programmer.

    So I went back to the plugin's page, changed my password to another wrong, and I tried one more time to publish a post. And the plugin told me "Success! Post was promoted". What does mean this?

    I want to solve my problem, but here is a idea for improve the plugin. Why does not the plugin show a "sucess!" if all was OK?

    Can anyone offers me a way to looking for a solution? Any words to search with google?

    Thanks in advance.

  11. 161
    Derek VOF United States »
    commented, on 08/Apr/10 at 8:20 pm # :

    Hi Ozh –

    Handy plugin. Seems to work great when I hit "Publish" from within WordPress, but if I schedule a post, it never makes it to Twitter. Is that a limitation of the plugin or am I missing a setting? The shortened URL is created and ready to go at the bottom of the page, but it never hits Twitter.


  12. 162
    Ozh France »
    said, on 08/Apr/10 at 10:40 pm # :

    Derek VOF » I thought this issue had been fixed a while ago. Will have a look.

  13. 163
    Edmar Brazil »
    wrote, on 16/Apr/10 at 9:33 pm # :


    I'm very happy with the yourls plugin. But, I'm having problem with my own yourls installation. The system had shortened correctly my URLs until finish the sequential
    numbers 1-8. After, when beggining letters, a, b and c was perfect. But, d sent to error page, "e" too, and now I couldn't use my own yourls.

    Excuse my bad english, but can you help me?

    You can add msn@edmarrp.org for this.

    Thank you.

  14. 164
    Fabrizio Castagnotto (faquick) Italy »
    replied, on 21/Apr/10 at 3:04 pm # :


    I like a lot Yourls and this plugin. I have a couple of "feature requests" for future development, I hope they are simple enough to be added:

    first one, can you use something else instead of "from API" to sign twits from this plugin? the optimum would be the name of the blog, like "tweetable" does

    second, changing the way it generates short urls: now it creates them with a sequential number, what about creating random urls?

    thank you and keep your great work ;)

  15. 165
    moh ini sin India »
    commented, on 22/Apr/10 at 1:46 pm # :

    Ive configured everything, but still it's not working when i use scheduled posts.

    kindly help me..

  16. 166
    Nisse Sweden »
    thought, on 01/May/10 at 2:01 am # :

    What should I write instead of "/home/you/"-part of the example for local installation?

    "Example: /home/you/site.com/yourls/includes/config.php"

    I can't figure it out.

  17. 167
    Ozh France »
    commented, on 01/May/10 at 10:07 am # :

    Nisse » the physical path of the config.php

  18. 168
    Sutherland United States »
    commented, on 06/May/10 at 5:17 pm # :

    Hey Ozh, thanks a ton for this plugin, it's been a huge help to me. With that said, it's worked flawlessly for the most part. Lately though, it started occasionally creating 2 short urls for the same long url at the time of posting. Initially my yourls installation was set to disallow multiple shorts, but somehow it managed to do it anyways and break the duplicate short urls. I fixed the problem of the broken short links by enabling multiple short urls for one long url, but it's still occasionally creating duplicates at the time of posting. How should I troubleshoot this, or what information do you need?

    Thanks again for the great plugin!

  19. 169
    BandonRandon United States »
    commented, on 11/May/10 at 9:59 am # :

    Hey OZH,

    You may still be working on updating this to work with WP 3.0 and the updated wpme_get_shortlink functions. I just wrote a short blog about what I did to clean up the UI a little bit so there is only one defualt "Get Shortlink" button instead of adding a second. This should work with WP 2.8 and above still. http://bandonrandon.wordpress.com/2010/05/10/yourls-wordpress-plugin-update-for-3-0/

    Let me know what you think. I hope it's at least a little bit helpful in the dev of this plugin. Thanks!

  20. 170
    AGb United States »
    replied, on 24/May/10 at 7:51 am # :

    FYI – I found that having special characters in my Twitter password would result in the WordPress to Twitter plugin fail (silently) to tweet the post and short url. Changing the password to just letters and numbers solved the issue.

  21. 171
    Ozh France »
    wrote, on 24/May/10 at 11:00 am # :

    AGb » Interesting feedback. What kind of special chars?

  22. 172
    AGb United States »
    thought, on 24/May/10 at 4:34 pm # :

    Ozh – The special characters !@#$%^&*. It was a bit odd because it was inconsistent. I have used these in other passwords and not had problems with Twitter. But "&" seems the most troublesome. A single inclusion and it fails. Whereas it appears three or more (different) characters in a password are needed to produce an error.

    It was actually another application that was reporting authentication errors with Twitter accounts that exposed the problem. The dev there narrowed it down to the special characters. Once we changed the passwords to simple alphanumeric, the authentication errors stopped. YOURLS was having problems with these same accounts. Thus changing the login settings in YOURLS to alphanumeric, your plugin would then post to Twitter. Victory!

  23. 173
    Lars Switzerland »
    thought, on 26/May/10 at 9:06 pm # :

    Nice plugin, thanks for that work! :) Will it be updated to oAuth because Twitter stops supporting basic authentication in June?

  24. 174
    Ozh France »
    commented, on 26/May/10 at 9:23 pm # :

    Lars » yes

  25. 175
    Christian Germany »
    wrote, on 27/May/10 at 7:37 pm # :

    is it possible to exclude a category? I added a sideblog via posterous and this posts needn't to tweet.

  26. 176
    Ozh France »
    thought, on 27/May/10 at 8:50 pm # :

    Christian » Look there http://code.google.com/p/yourls/issues/detail?id=248 this is a similar question

  27. 177
    David Jackmanson Australia »
    said, on 28/May/10 at 4:24 pm # :


    My posts are posting to Twitter – but without the short URL.

    When I go to the edit page, I get the "bleh – the short URL service is uncontactable" message.

    I am running yourls on djckmn.com and my blog on brisbaneblog.info

    Both of these sites are on the same account at NearlyFreeSpeech.net

    Above, you said logging into Yourls should work IF WP was auto-updating. I was unable to upload pictures to WP until I followed the instructions in this article: http://snarp.dreamwidth.org/124165.html

    I was wondering if the fact that NFS runs in safe mode is what is stopping the plug-in communicating with the main yourls install? I've already tried changing all the files in djckmn.com to web group but that didn't do anything. I've also chmodded yourls-api.php to see if that would work, but that didn't help either.

    I have tried telling the plugin to check in /yourls-api.php, and /home/public/yourls-api.php – Neither of these has worked yet. I've tried several times to swap between the two of these, clearing my cache every time.

    Is there anything else you can suggest, or any more info you need?


    David Jackmanson

  28. 178
    Ozh France »
    said, on 28/May/10 at 4:59 pm # :

    David Jackmanson » probably a case of not getting correctly the path to config.php, are you positive you didn't get it wrong?

  29. 179
    David Jackmanson United States »
    said, on 28/May/10 at 5:16 pm # :

    Do you mean I have the wrong settings in my config.php file? I don't *think* I do, because yourls is working when I open it in it up in djckmn.com/admin

    Should config.php have just 'http://djckmn.com' or 'http://djckmn.com/home/public'?

  30. 180
    Ozh France »
    replied, on 28/May/10 at 5:39 pm # :

    David Jackmanson » I'm talking about getting the correct path of the YOURLS config.php (ie the /home/physical/path/to/yourls/config.php) so the WP plugin knows how to contact your YOURLS setup

  31. 181
    David Jackmanson United States »
    wrote, on 28/May/10 at 11:32 pm # :

    Ah ok. It's at http://djckmn.com/home/public/includes/config.php – I just double-checked to make sure.

    But I don't understand where to put this info into the WP plugin. I can only see a field asking for yourls-api.php.

  32. 182
    Ozh France »
    wrote, on 29/May/10 at 12:40 am # :

    David Jackmanson » That's a URL. The path is probably /home/public/includes/config.php then. Just look at the options in the plugin: case if YOURLS and WP are on the same machine (not necessarily same domain name), ie "Local", or not on the same machine, ie "Remote".

  33. 183
    David Jackmanson Australia »
    said, on 29/May/10 at 1:11 am # :

    I've been using "remote webserver". Although the two sites are both hosted on nearlyfreespeech.net, they are two different sites with different IP addresses.

    I've tried switching to "local" but that generates an error message – telling yourls to use local path /djckmn/home/public/includes/config.php gives

    Warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/djckmn/home/public/includes/load-yourls.php) is not within the allowed path(s): (/f5/brisbaneblog/:/nfsn/apps/php5/lib/php/:/nfsn/apps/php/lib/php/:/nfsn/content/content/nfsn/) in /f5/brisbaneblog/public/wp-content/plugins/yourls-wordpress-to-twitter/inc/core.php on line 129

    Warning: require_once() [function.require-once]: open_basedir restriction in effect. File(/djckmn/home/public/includes/config.php) is not within the allowed path(s): (/f5/brisbaneblog/:/nfsn/apps/php5/lib/php/:/nfsn/apps/php/lib/php/:/nfsn/content/content/nfsn/) in /f5/brisbaneblog/public/wp-content/plugins/yourls-wordpress-to-twitter/inc/core.php on line 134

    Warning: require_once(/djckmn/home/public/includes/config.php) [function.require-once]: failed to open stream: Operation not permitted in /f5/brisbaneblog/public/wp-content/plugins/yourls-wordpress-to-twitter/inc/core.php on line 134

  34. 184
    Ozh France »
    thought, on 29/May/10 at 10:05 am # :

    David Jackmanson » this is getting nowhere. What is the fucking *paths* of YOURLS on your setup? Physical path, not URLs, not domains, not IP. Path. What you see when you SSH or FTP. For instance the path of your WP setup is /f5/brisbaneblog/public/.

  35. 185
    David Jackmanson Australia »
    wrote, on 29/May/10 at 10:21 am # :

    Um, thanks for swearing at me. This no doubt seems simple to you but I'm struggling with it.

    When I log into my FTP client I see /home/public/includes/config.php

    My site information screen says my root path is /f5/djckmn

    Therefore I assume (athough I could be wrong) that the path to the yourls config file is /f5/djckmn/home/public/includes/config.php

  36. 186
    Udegbunam Chukwudi | StrictlyOnlineBiz Europe »
    commented, on 29/May/10 at 10:33 am # :

    Dear Ozh,

    Seems like you're having a rough day. How's about you take a break from replying to David and come back when you're less stressed out.
    I know the feeeling and I do get like that sometimes with patients @ the hospital.

    Take care and BTW the plug-in/code still works pretty well on my blog. Have a fabulous weekend. Cheers ;-)

  37. 187
    Ozh France »
    wrote, on 29/May/10 at 12:10 pm # :

    David Jackmanson » Try /f5/djckmn/public/includes/config.php

  38. 188
    Ozh France »
    commented, on 29/May/10 at 12:13 pm # :

    Udegbunam Chukwudi » looks like a sound advice ;)

  39. 189
    David Jackmanson Australia »
    thought, on 29/May/10 at 12:30 pm # :

    Hi, thanks for the reply.

    Unfortunately neither /f5/djckmn/public/includes/config.php

    nor /f5/djckmn/includes/config.php works.

    They both generate the same errors on the "edit post" screen as in my comment here of 29/May/10 at 1:11 am

  40. 190
    Ozh France »
    commented, on 29/May/10 at 7:51 pm # :

    David Jackmanson » in other words, your host sucks. Sorry, don't know how to help you further.

  41. 191
    Udegbunam Chukwudi | StrictlyOnlineBiz Europe »
    wrote, on 29/May/10 at 8:53 pm # :

    @David Jackmanson: I think it's about time you contact your web host with regards to this issue. As Ozh said your web host might be to blame. Who do you host with by the way?

  42. 192
    David Jackmanson Australia »
    commented, on 02/Jun/10 at 1:06 am # :

    @Udegbunam Chukwudi,

    Sorry I didn't see this reply earlier.

    I'm hosted at NearlyFreeSpeech.net. I've been looking for help on the forums there for the last couple of days.

    They tell me it's likely the problem is caused by not using the $_SERVER['DOCUMENT_ROOT'] value to refer to the site's public directory, as detailed at:


    Since I have no idea what this means I'm looking to pay for a php programmer who can alter the plugin for me or write a new one to amke it work.

  43. 193
    Udegbunam Chukwudi Europe »
    said, on 02/Jun/10 at 11:46 am # :

    My advice to you would have been to change web hosts but if you are happy with them, you can stay put. In the mean time, you can check out this tutorial http://www.ampercent.com/branded-url-shortener-own-domain/6049/

  44. 194
    Ozh France »
    said, on 02/Jun/10 at 11:57 am # :

    David Jackmanson » changes are you cannot use the local method. Thus you need to rely on the remote method, where you input the *URL* to yourls-api.php (like http://sho.rt/yourls-api.php). If that doesn't work, well, that doesn't work. Find a better host.

  45. 195
    Andy United States »
    wrote, on 03/Jun/10 at 5:10 am # :

    @David Jackmanson – I host my blog on nearlyfreespeech.net and I was using Ozh's plugin for about a month before it stopped working. I went through much of the same process as you but simply could not get it working.

    In the end, I ended up going with Shorten2Ping by Samuel Aguilera and it has worked flawlessly. It does essentially the same thing as Ozh's plugin.

  46. 196
    David Jackmanson Australia »
    wrote, on 03/Jun/10 at 9:41 am # :

    I figured out how to make this work.

    I'd already tried using the remote method, which hadn't worked – *that's* why I was providing URLs earlier in this discussion.

    What did work, however, was to upload a copy of the config.php file for the YOURLS install on djckmn.com into a directory of brisbaneblog.info

    Then I went to the settings, selected the "local" option, and entered the /f5/brisbaneblog/ …. config.php path into the settings of the WordPress plugin.

    This worked. The plugin was able to read the details from the config.php file stored in the brisbaneblog.info directory and use those details to tell the install hosted at djckmn.com to create the short URL, pass it back to the plugin and send a tweet containing the title of a new post and the short link to the brisbaneblog twitter account.

    Of course I could have also just installed YOURLS into a subdirectory of brisbaneblog.info but that would have made the short URL longer than I wanted – I wanted them in the form djckmn.com

    Hope this helps anyone else with the same problem.

    Andy, thanks for the info, too – if my last shot at making this work had failed a backup would have meant I still had some hair left!

  47. 197
    Udegbunam Chukwudi Europe »
    said, on 03/Jun/10 at 10:22 am # :

    @David Jackmanson: Boy does it feel good to hear that you finally fixed it. Enjoy. ;-)

  48. 198
    Uwe Germany »
    said, on 04/Jun/10 at 3:01 pm # :

    Thx for the great work!

    Could you please make a selection to send an update tweet?
    Of course without making a new short url :-)

  49. 199
    Eddy Germany »
    thought, on 18/Jun/10 at 8:29 pm # :

    Hi i have a problem with the Plugin.

    Haveing YOURLS installed on the same Server as my WordPress only got me some Error's with the Plugin.

    So I installed YOURLS on my Mac so i could use it as a Remote Webserver.
    I got rid of the Error's but now 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!" …
    How can it not connect to my Mac when its still running ?

  50. 200
    Tuinslak Belgium »
    commented, on 20/Jun/10 at 12:50 pm # :

    Are you sure this still works with WP 3.0? It's been working fine for months, and since I updated to WP 3.0 the shortening is broken and I get the usual error: "Bleh. The URL shortening service you configured could not be reached as of now. This might be a temporary problem, please try again later!"

    The Yourls is located on a remote server, and as I said, it's been working great for ages. Until recently. Tried changing the username/psw, using another domain as URL (in case it was a DNS prob), …


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.