Shortlinks

Description

Shortlinks allows you to easily retrieve the shortlink for your WordPress posts, pages, categories, post_tags, attachments, custom post types, and custom taxonmies.

By default, WordPress uses links a query string ( ie: http://blog.aizatto.com/?page_id=3565 ) to load up your posts, pages, categories, etc. But when you enable permalinks, the query string is hidden by the WordPress rewrite rules. Having pretty urls is great, but also makes the website less flexible. For example, changing a posts published date will change the URL.

While we can’t control how other people will link to our site, we can control how we link to our internal sites.

By default, with permalinks enabled, when visiting WordPress with a shortlink, WordPress will redirect you to the permalink URL.

How It Works

Shortlinks hooks into the WordPress filter get_shortlink to enable shortlinks for all WordPress types.

You can use Shortlinks in your own theme or plugin.

To return the shortlink for a post, page, or custom post type, where $id represents the ID:

<?php echo wp_get_shortlink($id, 'post'); ?>

To return the shortlink for a category, where $id represents the category id:

<?php echo wp_get_shortlink($id, 'category'); ?>

To return the shortlinks for custom taxonomy, where $id represents the term id, and $taxonomy represents the custom taxonomy:

<?php echo wp_get_shortlink($id, $taxonomy); ?>

Installation

  • Download Now
  • Upload the shortlinks folder into your plugin directory.
  • Activate the plugin through the ‘Plugins’ menu in WordPress

Screenshots

Easily get shortlinks for posts

Easily get shortlinks for pages

Easily get shortlinks for a single page

Easily get shortlinks for categories

Why I Created It

WordPress supports shortlinks by default, but only allows the user to get the shortlink for a post. Finding it unacceptable, I created a plugin to get shortlinks for all content types.

Links

Change Log

v0.1 – 12th April 2010

  • Initial Release

Related posts

Tags

    No tags for this post.

4 Responses to Shortlinks

  1. epilasyon says:

    This post is in fact a nice one it helps new net viewers, who are wishing in favor of blogging.

  2. Lee Ann says:

    Ok maybe this is stupid – but where do I put that snippet of code so that this works?

  3. Callum says:

    In my tests, ?p=id shortlinks work for both posts and pages. They’re a little shorter than ?page_id=. I’m not sure why WordPress does not support ?p= shortlinks for pages automatically.

    I cruised your various sites. Interesting. I resorted to whois to find an email for you before I realised I could post a comment here on this plugin. I’ve published a somewhat popular plugin myself and I get fed up with people emailing me problems when I’ve specifically asked them to post comments, so I thought I better check here first! :-)

    Would you be so kind as to email me if you reply to this comment? I haven’t subscribed to the comment feed by RSS and I don’t see an email subscribe button on this blog.

    Oh, on a complete aside, while I think about it, would you be interested in forming a WordPress hosting cooperative?

  4. Pingback: Wordpress: condividere un post su Twitter senza plugin | Il Jester Web

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>