我有一个自定义脚本,允许添加每个表单提交,以将联系人添加到自定义帖子类型。但出于某种原因,它总是将数据添加到帖子中,而不是添加到帖子类型中。
到目前为止,我已经尝试了所有的方法,但没有找到我取出的表单的代码,因为该部分工作正常
if( !isset( $hasError ) ) {
$submit_to_contact_manager = array(
\'post_title\' => \'Request from \'. esc_attr(strip_tags($_POST[\'request_lastname\'])),
\'post-type\' => \'tpf_cnm\',
\'post_status\' => \'pending\'
);
$contactmanager_id = wp_insert_post($submit_to_contact_manager);
if($contactmanager_id)
{
// Update Custom Meta
update_post_meta($contactmanager_id, \'tpf_first_name_preorders\', esc_attr(strip_tags($_POST[\'request_firstname\'])));
update_post_meta($contactmanager_id, \'tpf_last_name_preorders\', esc_attr(strip_tags($_POST[\'request_lastname\'])));
update_post_meta($contactmanager_id, \'tpf_email_preorders\', esc_attr(strip_tags($_POST[\'request_email\'])));
update_post_meta($contactmanager_id, \'tpf_preorder_desc\', esc_attr(strip_tags($_POST[\'request_message\'])));
update_post_meta($contactmanager_id, \'tpf_preorder_desc\', esc_attr(strip_tags($_POST[\'request_category\'])));
}
}
这里是post-type函数
add_action(\'init\', \'tpf_cnm_init\');
function tpf_cnm_init(){
$tpf_cnm_type_labels = array(
\'name\' => _x(\'Contacts\', \'post type general name\'),
\'singular_name\' => _x(\'Contact\', \'post type singular name\'),
\'add_new\' => _x(\'Add New Contact\', \'image\'),
\'add_new_item\' => __(\'Add New Contact\'),
\'edit_item\' => __(\'Edit Contact\'),
\'new_item\' => __(\'Add Contact\'),
\'all_items\' => __(\'View Contacts\'),
\'view_item\' => __(\'View Contact\'),
\'search_items\' => __(\'Search Contacts\'),
\'not_found\' => __(\'No Contacts found\'),
\'not_found_in_trash\' => __(\'No Contacts found in Trash\'),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Contacts\'
);
$tpf_cnm_type_args = array(
\'labels\' => $tpf_cnm_type_labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => _x( \'contact-manager\', \'URL slug\', \'your_text_domain\' ) ),
\'capability_type\' => \'post\',
\'has_archive\' => true,
\'hierarchical\' => false,
\'menu_position\' => null,
\'supports\' => array( \'title\', \'comments\', \'custom-fields\' )
);
register_post_type(\'tpf_cnm\', $tpf_cnm_type_args);
}
任何帮助都会很好我快疯了提前谢谢大家