2014-08-29 25 views
1

我想在模式窗口中使用短代碼。代碼在一個單獨的php文件中。我得到一個致命錯誤:調用未定義的函數單獨的PHP文件中的短代碼

這是模態環節的正常工作:

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

位置modal.php看起來是這樣的:

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

我怎麼能得到這個工作?

回答

0

您需要包含您的PHP文件,其中包含do_shortcode函數。做這樣的事情:

<?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> 
+0

仍然出現致命錯誤:調用未定義的函數 – Shae 2014-08-29 01:12:03

1

這沒有把戲。

<?php 
require('../../../wp-blog-header.php'); 
?>