Refer to the parameters section in the documentation for wp_insert_post
.
Custom fields (meta data) must be passed in the form of a key/value array with the parameter name 'meta_input'
.
Change
'post_custom_field' => $add
to
'meta_input' => array( 'post_custom_field' => $add )
To show the value, use the get_post_meta
function. get_post_field
is only for the native fields in the posts
table, not for custom meta data.
echo get_post_meta( get_the_ID(), 'post_custom_field', true );
Related Posts:
- Get post ID from wp_insert_post()
- Create page to handle form submission
- How to save contact form 7 data in Custom Post Types (CPT) [closed]
- Conditional two level dropdown filter for custom post type
- Dynamic dropdown custom post list based on dropdown selection
- Reason action hook won’t work with update_post_meta from frontend form? Alternative?
- How can I fix a slow redirect after form submit from frontend (no plugin)?
- How to embed form data within the ‘Add new post’
- Using shortcodes to parse POST request (containing the data from a front-end form)
- Linking three taxonomies with ACF
- Custom query form submission pagination
- How to add the post ID (or any other post data) to a Contact Form 7 mail?
- WordPress posts with multiple fields
- How to Submit Post Via cURL & PHP
- Send email button in custom post type backend
- How to query custom post types posts filtered by multiple custom taxonomies through a form selection
- How to retain $_POST data when submitting form to custom page
- Display users uploaded files as posts
- Post form as custom post
- Form action/link to render a plugin in WordPress front-end
- How to integrate a form (Ninja Form or Contact Form 7) with Custom Post Types?
- A form that can save/edit after first input
- How to make front end form only accept certain values
- Edit Custom Post Type on Custom Admin Page instead Post Admin
- Using POST method in meta box, no results
- Form action doesn’t work if slug isn’t same as custom post title
- 404 Error on form submission within custom post type
- Direct form to a custom page template
- How to selected value default in option list?
- Making a form for user to add new custom post with custom taxonomies and custom fields
- Submit Custom Postypes from frontend
- How to submit custom post type front end form when a user buy specific product
- How to upload two input files [closed]
- Change dynamically the dropdown list value
- Why it doesn’t create a custom post type after form submitting
- How to submit the date with ajax?
- ‘Simple’ Reservation System
- Attend event form with ajax
- WordPress retrieving $post based on random key in $_POST
- Change the term based on the value of a $variable using wp_update_post in submitting a form
- Guided post type create based on category tree
- Show ajax form resuslts in page
- Advanced search form with multiple custom fields
- custom search form for custom post
- Getting Custom post category from Form
- Submitting custom post from frontend,jQuery ajax, and custom validation – can’t find proper place to insert wp_insert_post()
- Understanding the workflow of form creation plugin
- Front end page submission form does not attach custom post type
- How to create a petition like form based on custom post types?
- Front-end form submission not creating post
- Forms with multiple element types using custom post types
- Displaying database table in backend of wordpress
- Submiting custom form give error 404
- From form submission values – dynamically update CPT “has_archive” slug and custom taxonomy “rewrite” slug value
- Custom plugin contact form connecting to mailchimp API
- How to add categories to a custom post type using wp_insert_post($new_post);
- Need some suggestions with Relationship fields and CPT/ACF
- Is there a way to edit non-custom term attributes?
- Add first letter of titles to array, then compare arrays
- Custom Taxonomy Category link
- Displaying a Custom post type per day
- Adding something to the_content
- HowTo: Custom Post Type (Meta) to Custom Table
- Bootstrap accordion looping through posts incorrectly
- I’m having trouble getting the permalink sample on my custom post type edit page to work
- how to set a WP Plugin’s url
- Custom post type sorting: alphabetical order
- Getting 400 Bad Request on AJAX Call
- Is it a good idea to add a column to the posts table?
- Remove Quick edit for custom post type?
- How to hook WP initialization without modifying functions.php
- Main query not querying any posts in custom taxonomy template
- Slug Confusion Between Post and Custom Post types?
- WordPress custom slug rewrite
- Which Template Page Should I Use?
- How to change path for default WordPress blog posts?
- Custom Empty Results page for my Custom Post Type
- How to find a specific post_type using its “rewrite slug”?
- CRUD operations in wordpress
- How to get a custom type post data when it has a connection with another custom type post?
- How do I create an overview page with custom calculations from a post-type?
- wp_insert_post wrong post type [closed]
- disable quickedit for specific custom post type user role
- custom post type template
- WordPress Picks Up Wrong Template for Custom Post Type Archive Page
- Get Post Terms of Current Post (selected taxonomy term) – How to get only the taxonomy value and not “Array ( [0] => taxonomy term )” in the frontend?
- Replace dynamically content in a custom database table when a custom post is created
- How to hyperlink content from archive page with custom post-type
- Add post meta programmatically to attachment
- Loop increase number
- custom post for slider
- Custom post type showing same Post on all Pages
- WP Query ‘posts_per_page’
- How to display custom post type tags?
- Featured image size in column
- Associate page w/ specific single post template?
- WordPress Custom Post Type – show only certain posts that have specific taxonomy set
- Multiple pages per post (not pagination)
- Submitting Custom Post Types with custom fields from Front-end form
- Custom WP_Query always respond with 200 status even when no entry