admin管理员组文章数量:1314246
I am trying to add a new post via the front form. This is how it looks:
I insert the form in the right place via get_template_part
, here is the form itself:
<form class="consult__form-q" id="consultations-form" action="" method="post">
<label>Задать вопрос</label>
<input name="name" type="text" placeholder="Ваше имя" required>
<input name="mail" type="text" placeholder="Email" required>
<input name="theme" type="text" placeholder="Тема" required>
<textarea name="text" placeholder="Задайте свой вопрос тут" required></textarea>
<button type="submit">Задать вопрос</button>
<input type="hidden" name="submitted" id="submitted">
</form>
<?php submit_consultations_form() ?>
Here is the handler function itself, I put it in function.php
, I checked it for sure:
function submit_consultations_form()
{
if (isset($_POST['submitted'])) {
$post_data = array(
'post_title' => wp_strip_all_tags($_POST['theme']),
'post_content' => wp_strip_all_tags($_POST['text']),
'post_author' => wp_strip_all_tags($_POST['name']),
'post_type' => 'questions',
);
$post_id = wp_insert_post( wp_slash($post_data) );
}
}
The problem is that the new post is simply not being added. What am I doing wrong?
本文标签: formsNot adding a new post
版权声明:本文标题:forms - Not adding a new post? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741965432a2407517.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论