WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
<?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.

share|improve this question

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.

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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