【发布时间】:2016-07-07 13:41:25
【问题描述】:
为什么我的自定义函数在 WordPress 中被调用了两次?
例如我在functions.php中有这个函数:
function your_function_name() {
if(isset($_POST['your_var'])) {
// return $error;
echo '<p class="alert alert-danger"><span class="close" data-dismiss="alert">×</span> Work NOT submitted! Please correct the error(s) below.</p>';
}
}
我的模板:
<?php
your_function_name();
?>
<form class="form-submission" method="post" action="">
<input type="text" class="form-control" placeholder="Name" name="your_var">
...
提交表单后,我的屏幕上出现了两次<p class="alert alert-danger"><span class="close" data-dismiss="alert">&times;</span> Work NOT submitted! Please correct the error(s) below.</p>。一个是 在 html 标记之前,另一个是在正确的位置:
<p class="alert alert-danger"><span class="close" data-dismiss="alert">×</span> Work NOT submitted! Please correct the error(s) below.</p><!DOCTYPE html>
<html lang="en-US" class="no-js">
<head>
....
<p class="alert alert-danger"><span class="close" data-dismiss="alert">×</span> Work NOT submitted! Please correct the error(s) below.</p>
<form class="form-submission" method="post" action="">
<input type="text" class="form-control" placeholder="Name" name="your_var">
...
第一个之前 html标签应该不存在,但它确实存在!为什么?我该如何解决这个问题?
我希望消息出现在 form 标记之前,而不是 html 标记之前。
【问题讨论】:
-
你能告诉我你用这个模板做什么吗?我的意思是在博客或登录等中。或者您是否在默认模板中更改此设置?
-
can you please tell me for what you use this template?提交表单。就像在contact us页面上一样。这是一个自定义页面。
标签: php wordpress wordpress-4.5.2