function yummy_sounds_custom(){
add_menu_page(
__( 'Custom Menu Title', 'textdomain' ),
'Licence',
'manage_options',
'licence',
'licence_fields',
'',
6
);
}
add_action( 'admin_menu', 'yummy_sounds_custom' );
/**
* Display a custom menu page
*/
function licence_fields() {
?>
<h2>Fill the licence details</h2>
<form method="post" action="">
<div>Licence Title :</br> <input type="text" name="title" /></div>
<div>Licence Tagline :</br> <input type="text" name="tagline" /></div>
<div>Price :</br> <input type="text" name="price" /></div>
<div>Currency Symbol :</br> <input type="text" name="symbol" /></div>
<div>Description :</br> <textarea rows="7" cols="50" name="description"></textarea></div>
<div><input type="submit" value="Submit" name="submit"></div>
</form>
I am new for customization of wordpress so i have no idea how to save data in wordpress table .I am creating this form in custom admin menu and want to save data in post_meta how i can do it any help
我是自定义wordpress的新手,所以我不知道如何在wordpress表中保存数据。我在自定义管理菜单中创建这个表单,并想在post_meta中保存数据我怎么能做任何帮助
Thanks in advance
提前致谢
2 个解决方案
#1
1
You could involve Wordpress Ajax functionality for this: Wordpress Codex.
您可以使用Wordpress Ajax功能:Wordpress Codex。
Save data with update_option and read it with get_option functions. This is scenerio for single license.
使用update_option保存数据并使用get_option函数读取它。这是单一许可的场景。
If you like to create collection of licenses, just like posts for example, you must create new custom post type. Then you will have post id in new post type, and you could use update_post_meta and get_post_meta.
如果您想创建许可证集合,例如,就像帖子一样,您必须创建新的自定义帖子类型。然后你将在新的帖子类型中有帖子ID,你可以使用update_post_meta和get_post_meta。
#2
0
post_meta's datas are linked to a specific post, if you want to save global data you need to use update_option and get_option.
如果要保存使用update_option和get_option所需的全局数据,post_meta的数据会链接到特定的帖子。
#1
1
You could involve Wordpress Ajax functionality for this: Wordpress Codex.
您可以使用Wordpress Ajax功能:Wordpress Codex。
Save data with update_option and read it with get_option functions. This is scenerio for single license.
使用update_option保存数据并使用get_option函数读取它。这是单一许可的场景。
If you like to create collection of licenses, just like posts for example, you must create new custom post type. Then you will have post id in new post type, and you could use update_post_meta and get_post_meta.
如果您想创建许可证集合,例如,就像帖子一样,您必须创建新的自定义帖子类型。然后你将在新的帖子类型中有帖子ID,你可以使用update_post_meta和get_post_meta。
#2
0
post_meta's datas are linked to a specific post, if you want to save global data you need to use update_option and get_option.
如果要保存使用update_option和get_option所需的全局数据,post_meta的数据会链接到特定的帖子。