如果您正在处理自定义主题,我相信使用页面模板和WordPress的wp\\U ajax功能更容易完成。
该表单可以包含在页面中,使用<?php get_template_part(\'form\',\'0f-50-question\') ?>
.
下面是表单的伪代码
<form id="quite-a-long-form" action="<?php echo admin_url(\'admin-ajax.php\'); ?>" method="post" class="form" >
$step = $_GET[\'step\']
if $step = 1
//first section of question
echo <label>
echo <input>
echo <label>
echo <input>
else if $step = 2
//second section of question
echo <label>
echo <input>
echo <label>
echo <input>
else if $step = 3
//third section of question
echo <label>
echo <input>
echo <label>
echo <input>
// just repeat for all sections
endif
<input type="Submit">
<?php wp_nonce_field(\'input-answer\',\'security-code-here\'); ?>
<input name="action" value="input-answer" type="hidden">
</form>
对于将处理该文件的php
function process_add_transfer() {
if ( empty($_POST) || !wp_verify_nonce(\'security-code-here\',\'add_transfer\') ) {
echo \'You targeted the right function, but sorry, your nonce did not verify.\';
die();
} else {
// do your function here
wp_redirect($_POST[\'_wp_http_referer\'].\'?step=\'.$index_of_the_next step);
}
}
希望这有帮助