Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
<?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

2 Answers 2

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

 
discard

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.