One of the most powerful elements offered by the WordPress Shortcodes plugin is the link set of shortcodes. With this set of shortcodes you can easily create dynamic adaptable links to any content on your site, which are optimized SEO links.
One big problem with WordPress vanilla is that there’s no way to easily cross-reference content. So for instance when you add an attachment to your post, like an image, using the media uploader interface, WordPress simply places an HTML
img tag with the absolute URL to that image into the post’s content.
This works fine when you’re just maintaining a simple blog initially but creates problems further down the line. For instance suppose you used to keep your blog at example.com/blog but now you want to move it over to blog.example.com, now you’re in a bit of trouble.
What you’ll need to do is go into the database and do a hard replace of all absolute URLs and paths to any links or medias with your old site address, ouch! Not only is this cumbersome, especially if you don’t have much experience with SQL, but it’s also unsafe and potentially risky if you mess up.
Granted there are plugins that ease the above process but that still doesn’t remove the risks and the additional work required to port content references across domains. You might think a sneaky way of preventing this problem would be to use relative URLs but unfortunately relative URLs present many problems, especially in regards to SEO.
Prevention is the best cure
This is where the WordPress Shortcodes plugin comes to the rescue. Its goal is to prevent the above problem while still having absolute URLs that don’t hinder your SEO performance. This is achieved by using the various
link_xyz shortcodes, which create dynamic links, constructed from unique identifiers for the referenced content.
For instance suppose you want to link to a post on your site, instead of creating the anchor tag directly with the absolute URL you would use the following shortcode:
[link_post id="1" name="hello-world"]
The above will create a link to your post whose ID matches “1″ or whose permalink matches “hello-world”. Why specify both
name you might wonder, isn’t one of the two enough? The answer is yes, one is enough but one of the nifty features of the plugin is the priority-based matching mechanism.
What this means is that the
link_post shortcode will first attempt a search of the post with the ID that was specified in
id and if it fails it will search for a post with permalink name as specified in the
name parameter. This gives you a lot of flexibility in terms of references and cross-linking on your site.
For example if you use the
name parameter for all of the
link_page shortcodes you can then use this to globally switch all of the links on your site to a new post/page simply by changing the permalink on that specific post/page to match the
name attribute you used in those shortcodes. This will make all of the links update immediately and automatically and could be used to compare rankings of different posts/pages for SEO purposes.
You might have noticed the
link_post shortcode did not provide any text for the link, so how does the text display on the front-end? By default the plugin uses the specific post or page title but you can change this simply by specifying a content for the shortcode, like this:
[link_post id="1" name="hello-world"]My amazing post[/link_post]
But is this all that the link set of elements in the WordPress Shortcodes plugin offer? Absolutely not! There’s much much more. You can use the set to link all kinds of contents on your site, including posts, pages, media items, users/authors, categories, tags and custom post types and taxonomies.
You can easily create links to media attachments:
[link_media id="124"]My Media attachment[/link_media]
This is an example on how to render just the thumbnail of a post (or media attachment) at a specific size using custom templates:
[link_post name="hello-world" size="80" template="custom"] %%thumbnail%% [/link_post]
If instead you want to render the full size image for a specific media attachment instead of the thumbnail, just use “full” for the
[link_post name="hello-world" size="full" template="custom"] %%thumbnail%% [/link_post]
This is an example on how to create a so called author card or user panel:
[link_user id=1 template="card-full"]
There’s many more combinations of link elements and parameters that you can use for those shortcodes. In combination with templates and especially custom templates that allow you to use tag to create your own markup there’s a huge amount of possibilities. And this is just a small subset of all the features the WordPress Shortcodes plugin provides, just give it a shot and download it absolutely for free!