<?php /*template name: my template*/ ?>

<?php get_header(); ?>

<?php get_header(); ?>

<?php echo do_shortcode('[STORE-LOCATOR]'); ?>

<?php if ( have_posts() ) : while ( have_posts() ) : the_post();  ?>
<?php the_content(); ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?> 

I use this code in my template, and I also use my short code. But this short code is working only in default theme not in custom theme so please let me know how to use shortcode in custom theme.


You should have the function defining the shortcode in your custom theme too.

Look for the add_shortcode function in your default theme and add the add_shortcode line and it's callback function to your theme's functions.php file.


Firstly, you're calling get_header twice - and the footer not at all.

Secondly, where/how did you add your shortcode?

In order to create a new shortcode [short_code_name] and use it, you have to do the following:

add_shortcode( 'short_code_name', 'short_code_func' );
function short_code_func() {
    return "That's my shortcode. Yay!";
} // function short_code_func

You could do this in your theme's functions.php file, for instance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.