0017

Shortcode to output templates and domain URLs in WordPress

Shortcode to output templates and domain URLs in WordPress

2013.3.18

When you specify an image in a post, you can also specify an image in the theme file, “I want to specify the image in the theme file”, “Register to media It’s a pain in the ass to do so. It’s a hassle to do it”.
In such a case, you can simply copy and paste it into functions.php and use it as a short I wrote down the code.

Confirmation

Copy and paste the following code

Copy and paste the following code into functions.php.

 function templateUrl() {
    return get_bloginfo('template_url');
}
add_shortcode('theme', 'templateUrl');

Then, just copy and paste the [theme] into the post and the URL will be reflected.

When you want to use a domain URL

If you want to make it a domain URL, add the following.

 function baseUrl() {
    return get_bloginfo('url');
}
add_shortcode('domain', 'baseUrl');

Then, just copy and paste the [domain] into the post and the URL will be reflected.