Can you just tell me how I can grab the input value for “name” and add the entry to custom_post_type?
Sure thing:
if ( isset( $_POST['name'] ) ) {
$name = sanitize_text_field( wp_unslash( $_POST['name'] ) );
if ( $name ) {
wp_insert_post(
array(
'post_title' => $name,
'post_type' => 'my_post_type',
'post_status' => 'publish', /* Or "draft", if required */
)
);
}
}
Related Posts:
- Custom Post Type with Input fields to seperate table on database.
- Add Settings to Custom Post Type
- Possible to add another setting to ‘Front page displays’ setting for Custom Post Type
- How to add custom settings to the menu of custom post types?
- Should I use custom post types or a custom database tables for plugin development?
- Where are wordpress custom types stored?
- Delete all posts of a custom post type—efficiently
- Where, When, & How to Properly Flush Rewrite Rules Within the Scope of a Plugin?
- Custom Post Type Settings page, choose page to display archive
- Custom Post Types, or completely custom?
- Right way of storing large number of custom post fields
- How to use custom database tables for custom post types?
- Get all posts from custom post type and insert in select input as metabox
- Custom Post Type or Custom Tables
- Custom post type or just use custom fields
- Create Pages from Database
- Use Custom Database with Custom Post Type
- Custom Search | Wrong output & question
- How do I write this SQL statement for Posts written in last 24 hours?
- Save or update data when custom post published
- Custom post type Vs. data in own table
- Save custom post type in different table
- Using posts and postmeta table to store custom Address Book Plugin data
- How to: add option to add more checkboxes on custom post type
- How to use custom post type APIs, but use a different db table
- Developing WordPress on Kubernetes
- Recommended custom post type structure for TV Schedule site?
- Settings API with custom post type menu limitation
- Good way to store content and settings for an RSS plugin
- Custom Post Type, Saving Multiple Checkboxes
- WordPress post count not showing for custom post type author
- Where to store custom tagging data associated with a custom post type
- wpdb custom post_type problem
- Adding custom tables to WordPress
- WP All Import – Using Xpath to set a select value
- Update menu when saving settings
- Sorting custom post type columns with external data and without meta values
- Am I using the flush_rewrite_rules function in the right place?
- How to use custom taxonomies to reference complex relationships?
- Create a clone from one WordPress site to another in a few minutes
- Database to page routing API?
- How to automatically set ‘default image size’ for specific Custom Post Type
- Custom setting to show or hide field
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- Options page – dropdown of users
- How to change wp prefix for custom post type only?
- Is it possible to store Custom Post Type data in separate set of tables and still have wp_post class functionality?
- Add update or delete database records using custom post type
- How to import a custom MySQL DB table into a WordPress custom post type
- Edit Custom Post Type on Custom Admin Page instead Post Admin
- WP_Query orderby and tax_query
- Importing Data from a Non-WordPress database, into WP
- How to organise this data within WordPress
- Organize WordPress site, so it can maintain with huge database
- Save custom post type to external database
- Sizing textarea field in custom metabox
- Settings API – save multiple tabs at once
- Show data from one Custom Post Type in another Custom Post Type
- Specifying meta field’s column type in Database using add_post_meta
- Replace dynamically content in a custom database table when a custom post is created
- Running a song lyrics site on WordPress
- Dump custom post type database
- Should I use custom taxonomies or not?
- Designing a custom post type with a minimum number of meta fields
- Set a hard-coded page-template (post-type-archive) as home/front-page of my wordpress blog?
- populate array with posts
- Allow front end users to add data to a custom post type
- WordPress hook which triggers on post import
- Update all published posts at once
- Entity to store contact form entries?
- WP Page Options Array
- Is it possible to sort metabox teaxtarea values?
- Ideas to connect external database table to wordpress posts as custom field source
- Database alteration: users who voted
- WordPress as a frontend website for iOS app [closed]
- shopping cart plugin development
- Using custom post types WordPress network
- delete duplicate meta_value with same post_id
- custom post type: own database table structure and custom “new-post” interface
- Import External XML
- Creating on-page options for Custom Post Type
- Say I have a tech blog, how best would I store technical specs for a phone, if i use custom post types
- Custom Post Type Meta Box Text Input Field Won’t Save When Blank
- Display custom-post type based on the Title matching the current selected value
- How can I increase the post count for custom post types only?
- How do you make relational post types in WordPress? [duplicate]
- Having a repeating custom field in admin custom post type, what I’d go better with, for DB’s sake? ACF repeater or query a different post type?
- Whats the best practise on how to store json data from a custom settings page?
- Does this archive template part look like its making too many calls to the db?
- Right way to store a large set of similar information on website? [duplicate]
- when looping through custom post data not appearing
- WordPress Settings API Overrides My Previous Value
- custom post types, custom fields and normalization
- Custom post type and custom taxonomy key lenght & query performance
- How to add dynamic fields on wordpress custom post type page in admin section
- How select query is generated in a Custom Post Type?
- dynamic vue widget inside custom post
- Create 3 Levels of relations with WordPress
- Exporting Post type from one theme and importing it to another theme
- How to replicate data storage and querying using WordPress. Custom posts/fields or Custom db tables?