I believe there are many reasons for themes to use this function or add it to your WordPress web site. I will briefly discuss a couple of the ones that come to mind. Note, if you are using the default permalink structure this may not be for you as the_shortlink() creates a URL that looks just like it.1
If you are new to WordPress and are still experimenting with the permalink structure to best fit your needs, you might consider using this function to create internal links for your site. Using the URL generated by the_shortlink() will always resolve correctly, using the verbose URL of the permalink structure may cause issues if you change the structure and do not manually edit all the internal links you have previously posted.
Please note, by “internal links” I am refering to the links used within the content of a post or page on your site pointing to another post or page on your site. A WordPress installation has the “smarts” to correctly resolve the links it generates if you change the permalink structure but it will not go back and “fix” anything you manually typed yourself as part of your page or post entry.
There is great potential for the user, the designer, and the developer using this function. I recommend adding it to all themes. Here is the most basic default usage of the_shortlink():
<?php the_shortlink(); ?>
This is the code I have decided to use on this site:
<?php the_shortlink( __('Short Link'), '', ' | ', '' ); ?>
… which you can see just after the comments or subscribe link in the post meta details.
Of course you can always use the ‘Get Shortlink’ button found on the page and post administration panels to get your shortlink, but making use of this single line of code allows your readers to gain that same benefit, too.
- NB: If you have the WordPress.com Stats plugin installed and activated, the_shortlink() function will use the wp.me link shortening service; and, it will retain all of the usefulness I noted above.
- Sept. 9, 2010: Recent testing has shown the “Get Shortlink” button on the Edit Post panel will not appear unless a permalink structure other than default is used. This also affects the_shortlink() display functionality.