2015-10-13 51 views
0

我在一个WordPress主题中创建了一个计算器,代码如下所示;在Wordpress主题文件中执行PHP

<?php //Template Name: Quote ?> 
<?php get_header(); ?> 
<section> 
    <div class="container"> 
     <div class="row"> 
      <div class="col-md-12"> 
       <article> 
        <h1><?php the_title(); ?></h1> 
        <div class="post"> 
         <form method="post" action="<?php bloginfo('template_url') ?>/quote.php"> 

          Counter 1: <input type="text" name="counter1width"> x <input type="text" name="counter1depth"><br> 

          <input type="submit" name="submit" value="Calculate Now"> 
         </form> 

         <?php 
          if(isset($_POST["submit"])) { 
           $counter1width = $_POST["counter1width"]; 
           $counter1depth = $_POST["counter1depth"]; 

           echo $counter1width*$counter1depth; 
          } 

         ?> 
        </div> 
       </article> 
      </div> 
     </div> 
    </div> 
</section> 
<?php get_footer(); ?> 

这是错误消息我得到...

Fatal error: Call to undefined function get_header() in /home/landford/public_html/wp-content/themes/landfordstone/quote.php on line 2

回答

1

您不能调用qoute.php文件直接。

1) create new page template and in that page template write your code.

2) Create new Page and select the page template from dropdown.

3) Add that page url in form action.