Shortcode in separate php file

I am trying to use shortcodes within a modal window. The code is inside of a separate php file. I am getting a Fatal error: Call to undefined function

This is the modal link which works fine:

Read More
<a class="model-link" href="<?php bloginfo( 'template_url' ); ?>/location-modal.php">Location</a>

location-modal.php looks like this:

<div class="location-modal ">
  <h1 class="modal-title">Heading</h1>
  <p class="modal-para">test</p>
  <?php echo do_shortcode('[MYSHORTCODE]'); ?>
</div>

How can I get this working?

Related posts

Leave a Reply

2 comments

  1. You need to include your PHP file which contains the do_shortcode function. Do something like this:

    <?php require_once "functions.php"; ?>
    <div class="location-modal ">
      <h1 class="modal-title">Heading</h1>
      <p class="modal-para">test</p>
      <?php echo do_shortcode('[MYSHORTCODE]'); ?>
    </div>