Showing posts with label shortcode. Show all posts
Showing posts with label shortcode. Show all posts

Monday, August 13, 2012

Ultimate shortcode for displaying custom post types

Here you go, I made this shortcode to display any custom post type within your post or page. You can also use do_shortcode function to use this shortcode inside your php file.

Insert the following code inside your theme's functions.php and let the wordpress know about this newly created shortcode by add_shortcode() function.

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.

<?php
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.