Php 在Wordpress中使用表单和Get/Post
我有一个名为wc-info.php的页面,它是使用这个函数在一个名为plugin_admin.php的页面上加载的 部分内容如下所示:Php 在Wordpress中使用表单和Get/Post,php,wordpress,Php,Wordpress,我有一个名为wc-info.php的页面,它是使用这个函数在一个名为plugin_admin.php的页面上加载的 部分内容如下所示: <div class="welcome-panel-column"> <form action="POST"> <input type="text" action="" name="gtin_search"> <input type="submit" action="" name=
<div class="welcome-panel-column">
<form action="POST">
<input type="text" action="" name="gtin_search">
<input type="submit" action="" name="gtin_submit">
</form>
</div
试试这个
function custom_function() {
if ( isset( $_POST['gtin_search'] ) ) {
// Update to the function which you are going to use
get_gtin_woo_db($POST['gtin_search']);
} // end if
}
add_action( 'init', 'custom_function' );
我希望这会有所帮助。您是否尝试过添加操作('init','some_function');并检查post变量。然后将数据发送到你的函数?谢谢,但是这个函数会去哪里?在plugin或functions.php的root functions.php中,我更喜欢functions.php。
function custom_function() {
if ( isset( $_POST['gtin_search'] ) ) {
// Update to the function which you are going to use
get_gtin_woo_db($POST['gtin_search']);
} // end if
}
add_action( 'init', 'custom_function' );