我正在尝试构建我自己的第一个Wordpress主题。到目前为止一切都很好,但现在我正在为WP后端做设置页面,我在这里遇到了函数内部的问题。php:页面上有一个Slider,我有一个,你可以在那里输入你想在上面有多少图像。现在我希望每次我改变这个输入时,图像链接的输入数量都会改变。因此,当输入中有2时,图像的URL将有2个以上的iput。
到目前为止我得到了这个:
function theme_front_page_settings() {
if (!current_user_can('manage_options')) {
wp_die('You do not have sufficient permissions to access this page.');
}
?>
<form action="this" method="post">
<label for="num_carousel">Number of Carousel Screens:</label>
<input type="number" id="num_carousel" name="num_carousel" value="3" min="1" max="5" oninput="fieldsNum()"/>
</form>
<?php
for($count = 1; $count < $_POST['num_carousel']; $count++){
echo "<label for='num_carousel".$count."'>Carousel Screen</label><input type='text' name='num_carousel".$count."'/><br>";
}
}
这是正确的路吗?在第6行中,我将动作设置为"this",因为我不知道该如何引用自己的脚本。我该怎么做?这可能吗?
希望你能帮助我。黑色幻影
您的做法是正确的。
处理表单操作的惯用方法是"#"而不是"this"。