[英]Execute PHP Within a Wordpress Theme File
我正在我制作的wordpress主題中創建一個計算器,代碼看起來像這樣;
<?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(); ?>
這是我收到的錯誤消息...
致命錯誤:在第2行的/home/landford/public_html/wp-content/themes/landfordstone/quote.php中調用未定義的函數get_header()
您不能直接調用qoute.php文件。
1)創建新的頁面模板,然后在該頁面模板中編寫您的代碼。
2)創建新頁面,然后從下拉菜單中選擇頁面模板。
3)在表單操作中添加該頁面網址。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.