Monday, August 13, 2012

Wordpress - shortcode for current theme path

You can find this short code useful when inserting some file or image from the relative path of your theme. Simply copy and paste following code inside your theme's functions.php and use the short code in your Page/ Post editor.

function currentThemePath() {
return get_option('home') . '/wp-content/themes/activeThemeName/';
add_shortcode('myThemePath', 'currentThemePath');

Replace 'activeThemeName' with your current active theme name.
And use the short code [myThemePath] in your page/ post.

No comments:

Post a Comment