Wordpress WooCommerce:通过自定义插件向愿望列表添加一些列表
我有一个自定义插件,用户可以首先将列表添加到Wishlist插件(Woocommerce)中 我有一个自定义的分步表单,用户可以选择列表的数量(从1到10),并输入这些新列表的标题和描述 在我表单的最后一步中有Ajax请求 如何将这些列表添加到数据库中Wordpress WooCommerce:通过自定义插件向愿望列表添加一些列表,wordpress,Wordpress,我有一个自定义插件,用户可以首先将列表添加到Wishlist插件(Woocommerce)中 我有一个自定义的分步表单,用户可以选择列表的数量(从1到10),并输入这些新列表的标题和描述 在我表单的最后一步中有Ajax请求 如何将这些列表添加到数据库中 我试图通过wp_insert_post($my_post)添加,但我也应该为postETA表添加设置 您可以将表单结果另存为,结果另存为 将帖子类型设置为“非公共”且未设置为“不在搜索结果中” 如果在愿望列表上没有预先设置逻辑,您可以将数据设置为
我试图通过wp_insert_post($my_post)添加,但我也应该为postETA表添加设置 您可以将表单结果另存为,结果另存为 将帖子类型设置为“非公共”且未设置为“不在搜索结果中” 如果在愿望列表上没有预先设置逻辑,您可以将数据设置为数组,并将其保存在一个字段中 要将数据从前端(用户页)发送到后端(服务器),您可以使用或通过 将字段保存到自定义帖子类型示例。可能是由于站点中的字段名不同,因此根据字段键设置为
// Create post object
$my_post = array(
'post_title' => wp_strip_all_tags( $_POST['post_title'] ),
'post_content' => $_POST['post_content'],
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array( 8,39 ),
'post_type' => 'event'
);
// Insert the post into the database
$post_id = wp_insert_post( $my_post );
// Updating the meta data (custom fields values)
if ( isset( $_POST['_wishlist_email'] ) ) {
update_post_meta( $post_id, '_wishlist_email', sanitize_text_field( $_POST['_wishlist_email'] ) );
}
更多关于
如果此愿望列表来自ready插件,您可以查看插件代码以了解插件如何处理保存的愿望列表数据。您可以将表单结果另存为,并将结果另存为 将帖子类型设置为“非公共”且未设置为“不在搜索结果中” 如果在愿望列表上没有预先设置逻辑,您可以将数据设置为数组,并将其保存在一个字段中 要将数据从前端(用户页)发送到后端(服务器),您可以使用或通过 将字段保存到自定义帖子类型示例。可能是由于站点中的字段名不同,因此根据字段键设置为
// Create post object
$my_post = array(
'post_title' => wp_strip_all_tags( $_POST['post_title'] ),
'post_content' => $_POST['post_content'],
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array( 8,39 ),
'post_type' => 'event'
);
// Insert the post into the database
$post_id = wp_insert_post( $my_post );
// Updating the meta data (custom fields values)
if ( isset( $_POST['_wishlist_email'] ) ) {
update_post_meta( $post_id, '_wishlist_email', sanitize_text_field( $_POST['_wishlist_email'] ) );
}
更多关于
如果此愿望列表来自ready插件,您可以查看插件代码,查看插件如何处理保存的愿望列表数据。我发现:
WC_Wishlists_Wishlist::create_list($tittle));
我发现:
WC_Wishlists_Wishlist::create_list($tittle));
是的,我有使用Ajax jQuery.post的功能(ajaxurl、数据、函数(响应){…});然后->函数集\u post\u information(){…};我可以使用wp_insert_post()添加具有自定义post类型的新post;但是,我还需要在
wp_postemta
表中添加一些设置:我添加了一个示例,说明如何在通过返回的$post_id插入自定义帖子类型后保存字段谢谢!但对我来说,最大的问题是如何为\u wishlist\u订阅者
,\u wishlist\u项目
和\u wishlist\u共享键
字段获取数据。是的,我有使用Ajax jQuery.post的功能(ajaxurl,数据,函数(响应){…});然后->函数集\u post\u information(){…};我可以使用wp_insert_post()添加具有自定义post类型的新post;但是,我还需要在wp_postemta
表中添加一些设置:我添加了一个示例,说明如何在通过返回的$post_id插入自定义帖子类型后保存字段谢谢!但对我来说,最大的问题是如何获取\u wishlist\u订户
、\u wishlist\u项目
和\u wishlist\u共享键
字段的数据