gpt4 book ai didi

php - 将表单值保存在 WordPress 的 post_meta 中

转载 作者:行者123 更新时间:2023-11-29 10:41:04 25 4
gpt4 key购买 nike

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>

我是 WordPress 自定义新手,所以我不知道如何在 WordPress 表中保存数据。我正在自定义管理菜单中创建此表单,并希望在 post_meta 中保存数据,我如何才能做到这一点?

提前致谢

最佳答案

您可以为此使用 Wordpress Ajax 功能:Wordpress Codex

使用update_option保存数据并使用get_option函数读取数据。这是单一许可证的场景。

如果您想创建许可证集合,就像帖子一样,您必须创建新的 custom post type 。然后您将在新帖子类型中获得帖子 ID,并且您可以使用 update_post_metaget_post_meta

关于php - 将表单值保存在 WordPress 的 post_meta 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45477039/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com