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. Mike R says:

    Hello,

    I've been using the plugin on a couple of sites and now it is starting to fail, I assume that this is down to the Twitter API changes?

    My personal site slows to a halt when the plugin is activated now :(

    Any updates or tweaks I can make?

  2. Peter R says:

    I have the same issue with the oauth.
    only
    Logged on Twitter as @ ( followers)
    is displayed…

    When will there be a solution?

  3. Pisosse says:

    I have lost the twitter write field alltogether..

    :-(

  4. aldy says:

    Is this been updated? cos i cannot see 'yourls-api.php' file. and the Plugins name has changed, so the file directory were not the same as your guide.

    What should i choose if i installed the plugins in http://www.angelsempire.net//public_html/wp-content/plugins ? Local or Remote server?

    Please advice,

    Many thanks

  5. Ozh says:

    aldy » You didn't understand what the plugin is for. You won't find any yourls-api.php in that plugin.

  6. hobscotch says:

    Hi Ozh,

    I have the same problem like the other people. Failure:
    Could not authenticate with OAuth.

    How can we fix this problem?

    Best Regarts
    Sven

  7. Eitan says:

    Hi,

    Updated to wordpress 3.5 and YOURLS 1.5.5
    When submitting all details, pressing save changes goes to my local YOURLS install.php and does not save twitter settings.

    Help?

    Cheers!

  8. Igor says:

    Hi!

    Yourls is not working on WordPress 3.5.

    Please, help us! :)

  9. Ozh says:

    Plugin updated: all Twitter related functions removed. Read the plugin page for more.

  10. Makis says:

    Last plugin update broke WP backend

  11. Ozh says:

    Makis » Doh, much apologies to that, I had uploaded an incomplete file. This is fixed, I've just committed 1.6.1

  12. Makis says:

    No need to apology :)
    It was a good opportunity for me to thank you about your short url development and this plugin all together.

  13. Bob Decker says:

    I updated to the latest version of the YOURLS WP plugin yesterday, but it's redirecting me to install.php when I try to publish a new post on WP 3.5 and doesn't shorten the link. Is this a known bug? Is there anything I can do?

    Thanks so much for providing Twitter support in the past. We've surely been spoiled with it. It's another sign that the Twitter API guidelines will only hurt the company.

  14. Igor says:

    I have exactly the same problem that Bob Decker has just mention it.

  15. Ozh says:

    Bob Decker & Igor » I cannot reproduce this, using "Remote" or "Local" works fine for me. What version of YOURLS are you using? Did you try resetting all settings and configure the WP plugin again?

  16. Bob Decker says:

    I am on YOURLS 1.5. What settings should I try resetting? This didn't start occurring until I upgraded to WP 3.5.

  17. Igor says:

    @Ozh @Bob Derek

    I have reseted my plugin setting and now Yourls 1.6.1 is working fine.

    Thanks! :)

  18. Walter says:

    1.6.1 seems to not be working with WordPress 3.5.1 and 3.5.2 (just did the update to make sure). Sometimes after publishing a post, the Yourls page appears with an error saying it's already installed. Other times, it seems as if everything has worked, but no short link gets generated. I'm unaware of anything on my server that has changed other than wordpress versions. The last short URL that my installation created automatically was in April. My bookmarklet is still working correctly.

  19. Walter says:

    I should add to my earlier comment that per other comments here, I clicked the "reset" link in the plugin and re-entered my path to the server, but that didn't fix it.

  20. Justin King says:

    Great plugin, Thanks! It works perfectly if I have my caching plugin turned off… but when I have W3 Total Cache with Cloudflare turned on I get a ton of duplicate short urls created for each post. Any ideas what could be causing that? Any fixes? Also, I see there is a generate a new URL when "New Media published" but I can't seem to get that to work. I'm trying to get short URLS for the featured image on every blog post, any way to do that?

  21. bay like says:

    This plug-in installed, there is a long time and slow before entering the installation interface

  22. Alessandro Oliviero Degiusti says:

    Excelent!!! I love Yourls and WordPress!

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.