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 table中保存数据。我正在自定义管理菜单中创建此表单,并希望将数据保存在post_meta中,我该怎么做呢?

提前致谢

最佳答案

您可以为此涉及Wordpress Ajax功能:Wordpress Codex

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

如果要创建许可证集合(例如,像帖子一样),则必须创建新的custom post type。然后,您将拥有新帖子类型的帖子ID,并且可以使用update_post_meta和get_post_meta。

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

10-12 00:16
查看更多