【发布时间】:2014-07-28 04:24:54
【问题描述】:
我想创建自定义前端表单并将该表单上的数据作为帖子提交到 wp_post 表中。但我想在主题中做功能而不是作为插件。我正在使用来自 themeforest 的 wpestate 主题。
【问题讨论】:
标签: wordpress forms submission
我想创建自定义前端表单并将该表单上的数据作为帖子提交到 wp_post 表中。但我想在主题中做功能而不是作为插件。我正在使用来自 themeforest 的 wpestate 主题。
【问题讨论】:
标签: wordpress forms submission
你需要使用 wp_insert_post() 函数is well documented
所以:
创建帖子后,您可以通过这种方式添加元数据:
$new_post_id = wp_insert_post( $post_args, false);
if($new_post_id != 0){
//add all data you want
add_post_meta($new_post_id, 'your_key', 'your_value', false);
}
这里发生的情况是,如果一切正常 $new_post_id 应该存储您刚刚创建的新帖子的 id,您现在可以使用该 id 存储元数据。
【讨论】:
尝试使用 wp_insert_post 函数插入帖子数据,剩余信息可以在帖子元表中添加信息,
update_post_meta($post_id,'meta-key')
尝试使用链接,我认为这会提供帮助
https://wordpress.stackexchange.com/questions/103442/front-end-posting
【讨论】: