Your metas need to be passed to wp_insert_post()
as an array like so:
// Insert the post into the database
$post["id"] = wp_insert_post( array(
"post_title" => $post["title"],
"post_type" => $cpt["custom-post-type"],
"meta_input" => array(
"custom-field-1" =>$cpt["custom-field-1"],
"custom-field-2" =>$cpt["custom-field-2"],
)
"post_status" => "publish"
));
https://developer.wordpress.org/reference/functions/wp_insert_post/#parameters
Related Posts:
- How to Upload CSV Data into Custom Post Type Data with Metabox programmatically
- Where to put my code: plugin or functions.php?
- Mini-Site Strategy
- How to set a fall back template for a custom post type in a plugin?
- Where to put archive-{post-type}.php
- Row actions not showing? Why?
- How to append element after thumbnail
- Dynamic Custom Post Type Plugin
- need advice on how to do a lists using custom post types – taxonomy vs postmeta
- Get rewrite slug of custom post type in template
- Admin notice not displaying
- How to Get Current Custom Post Type Selected Taxonomy Term (Not All Terms)
- What’s the difference between same wp functions get_posts(); functions in different form?
- How to customize a permalink (URL) structure?
- Query & Order posts by custom fields
- Use custom metabox to update automatically a post after a given date
- custom comments form for custom post type
- Problems wp_insert_post and save_posts filter
- Redirect to another page using contact form 7? [closed]
- detect your custom post type in WordPress
- Show current custom taxonomy
- How exclude or skip post type with get_next_post_link
- WordPress: Custom User Role cannot access Custom Post Type | “Sorry, you are not allowed to access this page”
- How do I add custom HTML to the content of an archive page’s posts?
- How to Use Custom Meta Field Instead of CPT Title in Post URL
- Validate Custom Post Type fields
- Front end create custom post types
- Custom post type page with parameter
- Not Able to Add New Class To CPT Attachment Image
- Change Dropdown jQuery to show/hide but with default place holder that shows all
- Custom post category name showing empty
- How to store the third party script with HTML code in the wordpress custom input field?
- How to show the post which checkbox is not selected
- How to get the custom post data using post id in WordPress?
- Is it possible to get the specific content on the search page?
- Get next and prev item from custom WP_Query and Custom Post Type
- Error 404 change permalink term custom term taxonomy
- Plugin Development using classes – Public & Private Callbacks
- I have a random letter appearing before my content. Where to start looking for the cause?
- programmatically generated custom post type is created more than once
- Visualize info in just custom post_type in theme
- cpt not display inside nav menu
- How to use posts as tabs in a custom page?
- Custom Post Type has wrong label and is not found when called by a loop
- Front End users account with lots of user Roles (not Woocommerce)
- Custom post type that lets users create a set of posts?
- call a function when insert and update a custom post type
- Not Able to Get Custom Post Type in Single and Single-custom-post-type
- How to develop custom URL redirection
- Loop carousel slider in wordpress
- Issue on Counting CPT’s Under Taxonomy Term
- Not Able to Display Metabox Saved Checkbox and Selected option After Save/ Update
- How to manage wordpress knowledge base/wiki/posts collections
- Need some hints for my own WP theme development
- How to dynamically register custom post type
- Append taxonomy terms as class names in markup?
- How to: add option to add more checkboxes on custom post type
- Custom role capabilities to administrator not taking effect (no plugin)
- How do I add a custom button to my “edit” list? ( edit.php?post_type= ) beside “Add New”
- How to add multiple featured image in meta box in post editor?
- Custom Post Type .current-menu-item not applying on Custom Post Type Archive Page
- Assigning Multiple Layout Designs with Custom Pages in WordPress?
- How do you output custom code between posts in the loop?
- Show ACF field from custom taxonomy and display on the single template
- How to allow “Add New” capability of CPT when links to its UI are placed as a submenu?
- Change message given when deleting post from custom post type
- How to retrieve custom field types for all posts in WordPress/PHP?
- How to add notification in the sidebar of the administration panel when a Custom post type is created? [duplicate]
- Hierarchical or Non-hierarchical Custom Post Type in Real World Example
- do not show web page section when using advanced custom fields pro
- Display children and grandchildren of a custom post type
- how to set default value for checkbox in wordpress
- Best practice for adding posts in bulk
- How do I include drag-and-drop in a plugin?
- wordpress custom post type remove duplicate menu item
- How could I create a ‘private comments’ section on a custom post type?
- Using WPAlchemy metabox values in another metabox
- adding .current* tags to custom post types and taxonomies
- is_page_template not working as expected
- List terms from Custom Taxonomy
- Custom Post Type get_post_type_archive_link( $post_type ) returns false
- Integrating Orbit slider into wordpress through custom post type
- How do I create an archive page for standard posts?
- Am I not understanding plugins?
- How do I set the link in the Custom Post Type admin menu?
- How to List Thumbnails based on Custom Categories
- Is it possible to associate different kinds of custom post types one to the other?
- WP_Query search posts by custom post type and custom taxonomy
- Limit users by custom taxonomy and user roles
- Using Font Awesome as post thumbnail
- Adding Meta Boxes while Registering a Post Type in a Class
- How to have the right design for a custom post type without accessing themes
- Order WordPress Custom Taxonomy Pages & Pagination Not Working
- I am having a problem with form updating/editing WordPress post on the frontend
- How to filter out post type meta?
- How to rename image at uploading on specific plugin or post-type in WordPress
- How to make in WordPress admin panel sortable column for the custom field, that count the number of page impressions?
- Remove parent from custom post type
- handling csv data with a custom post type
- Page as a child of a Custom Post Type