Posted on

WordPress Shortcodes

Well, THIS was immensely helpful! If you change the WordPress Permalink settings, or later decide to nest your site in a directory under another, page and post links can suddenly break. Sometimes you need a slash or maybe a dot slash before a path, but if you change or move your site, all those references in your post content to other posts may need to be updated. Wouldn’t it be nice if there was a shortcode for the site url that would just maintain your links no matter what?

Here’s the link to the plugin page:
https://wordpress.org/plugins/peters-blog-url-shortcodes/

It even works if you need to go levels up outside your site’s directory. You can also use this to reference images in other directories.

This plugin also offers several other short codes, noted here in parentheses instead of brackets so as not to trigger the effect:

(blogurl) will generate http://www.yoursite.com/
(blogurl wordpress) will generate the URL to the root of your WordPress files, if they are in a different location than your site root
(blogurl noslash) will generate http://www.yoursite.com
(blogurl uploads) will generate http://www.yoursite.com/wp-content/uploads/
(blogurl uploads noslash) will generate http://www.yoursite.com/wp-content/uploads
(posturl id=375) will generate the correct permalink for the post with an ID of 375; for example, <a href=”(posturl id=375)”>post about this plugin</a> would generate post about this plugin
(templateurl) will generate the URL to your parent theme’s root
(childtemplateurl) will generate the URL to your child theme’s root