On: 2009/06/25 Viewed: 51376 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, Twitter 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 and send it to your Twitter account. The plugin also works with public popular services such as TinyURL, tr.im, is.gd or bit.ly.

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.

Features and configuration

Is a picture worth a thousand words? Here are 3000 words:

Plugin configuration:
screenshot-1

Title little helper: count characters to help you keep under the tweetable 140 char limit:
screenshot-2

From the Write screen, you can (re)generate short URLs and (re)promote your (old, for example) posts:
screenshot-3

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

Twitter message templates

As you can see in the main screenshot above, you can easily customize your tweets. What the screenshot doesn't tell you is that there are many more tokens available:

  • %U: the short url
  • %T: the post's title
  • %A: the author's display name
  • %A{something}: the author's 'something' as stored in the database. Example: %A{first_name}. See get_userdata(). Use this if for instance you're running a multi author blog and each author has a Twitter contact information.
  • %F{something}: custom post field 'something'. See get_post_meta().
  • %L: tags as plaintext and lowercase (space separated if more than one, up to 3 tags)
  • %H: tags as hashtags and lowercase (space separated if more than one, up to 3 tags)
  • %C: categories as plaintext and lowercase (space separated if more than one, up to 3 categories)
  • %D: categories as hashtags and lowercase (space separated if more than one, up to 3 categories)

Remember, though: 140 characters is *short*. Since the title (token: %T) will be added last, it may really get shrunked if you had too many hashtags and stuff.

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

If you're not using the Twitter part, you can add this to your theme's functions.php to disable the nag about updating Twitter informations:

PHP:
  1. add_filter( 'ozh_yourls_notice', 'omg_plz_remove_nag' );
  2. function omg_plz_remove_nag() { return ''; }

Feedback

Yeah. Go ahead.

Shorter URL

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

Metastuff

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

441 Blablas

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

  1. 401
    David United Kingdom »
    wrote, on 19/Jul/11 at 6:40 pm # :

    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. 402
    dig Peru »
    wrote, on 21/Jul/11 at 4:03 am # :

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

  3. 403
    Joe Canada »
    replied, on 07/Aug/11 at 12:28 am # :

    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. 404
    Sundar India »
    commented, on 23/Aug/11 at 2:25 pm # :

    @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. 405
    Travis United States »
    wrote, on 08/Sep/11 at 6:55 am # :

    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. 406
    Sujit New Zealand (Aotearoa) »
    said, on 18/Sep/11 at 12:25 am # :

    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. 407
    Ozh France »
    said, on 18/Sep/11 at 11:11 am # :

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

  8. 408
    Sujit New Zealand (Aotearoa) »
    wrote, on 18/Sep/11 at 11:19 am # :

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

    I guess, it will resolve my prob :)

  9. 409
    Ozh France »
    wrote, on 18/Sep/11 at 12:09 pm # :

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

  10. 410
    Oz Brazil »
    wrote, on 28/Sep/11 at 2:45 pm # :

    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. 411
    Ma Wenjian China »
    replied, on 01/Oct/11 at 9:58 am # :

    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. 412
    Ozh France »
    replied, on 01/Oct/11 at 10:28 am # :

    Ma Wenjian » Read this very page please.

  13. 413
    Francesco Italy »
    commented, on 01/Oct/11 at 1:34 pm # :

    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. 414
    Ozh France »
    replied, on 01/Oct/11 at 1:49 pm # :

    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. 415
    Richard Hay United States »
    wrote, on 01/Oct/11 at 10:13 pm # :

    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. 416
    Alex Mielus Romania »
    thought, on 04/Oct/11 at 4:39 pm # :

    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. 417
    Alex Alouit France »
    thought, on 27/Oct/11 at 1:19 pm # :

    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. 418
    Lars Switzerland »
    thought, on 23/Nov/11 at 11:39 pm # :

    Same as #417 here

  19. 419
    AQ Russia »
    wrote, on 27/Nov/11 at 11:33 pm # :

    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. 420
    Mike United States »
    commented, on 29/Nov/11 at 6:51 am # :

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

    Thanks!

  21. 421
    Cristian United States »
    thought, on 04/Dec/11 at 6:52 pm # :

    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. 422
    Abyss Argentina »
    wrote, on 09/Dec/11 at 4:24 am # :

    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. 423
    Mike United States »
    said, on 17/Dec/11 at 6:23 am # :

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

    Thanks!

  24. 424
    Hernandez Indonesia »
    thought, on 22/Dec/11 at 8:06 am # :

    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. 425
    Alex Germany »
    commented, on 26/Dec/11 at 8:13 pm # :

    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. 426
    Ed United Kingdom »
    thought, on 13/Jan/12 at 5:53 pm # :

    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. 427
    Travis United States »
    said, on 13/Jan/12 at 9:03 pm # :

    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. 428
    Pgrytdal United States »
    wrote, on 04/Feb/12 at 2:04 am # :

    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. 429
    Casregime Denmark »
    replied, on 05/Feb/12 at 10:59 am # :

    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. 430
    Jota Spain »
    wrote, on 06/Feb/12 at 1:05 pm # :

    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. 431
    Gav United Kingdom »
    commented, on 28/Feb/12 at 10:01 pm # :

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

  32. 432
    Renee Netherlands »
    commented, on 29/Feb/12 at 12:54 pm # :

    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. 433
    lastguru Latvia »
    thought, on 29/Feb/12 at 8:51 pm # :

    Do you plan to make the plugin support passwordlessAPI?

  34. 434
    Ozh France »
    commented, on 01/Mar/12 at 12:10 am # :

    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. 435
    Nerdvana United States »
    said, on 19/Mar/12 at 6:17 am # :

    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. 436
    Nick Denmark »
    replied, on 22/Mar/12 at 12:41 pm # :

    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. 437
    Thias Esseboom Netherlands »
    commented, on 27/Mar/12 at 5:44 pm # :

    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. 438
    DJQuad United States »
    said, on 01/Apr/12 at 7:08 pm # :

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

  39. 439
    SK United States »
    commented, on 17/Apr/12 at 4:14 pm # :

    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. 440
    Isaac United States »
    wrote, on 01/May/12 at 8:54 pm # :

    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. 441
    sfbay United States »
    replied, on 09/May/12 at 1:00 am # :

    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!

Pages: « 1 2 3 4 5 6 7 8 [9] 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.