This should work. It’s the way press-this gets the post id when you click the bookbarklet.
add_action( 'load-post-new.php', 'prefix_save_it' );
function prefix_save_it() {
// define some basic variables
$quick = array();
$quick['post_status'] = 'draft'; // set as draft first
$quick['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : null;
$quick['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : null;
$quick['post_title'] = isset($_POST['post_title'] ? $_POST['title'] : null;
$quick['post_content'] = isset($_POST['post_content']) ? $_POST['post_content'] : null;
// insert the post with nothing in it, to get an ID
$post_ID = wp_insert_post($quick, true);
if ( is_wp_error($post_ID) )
wp_die($post_ID);
$quick['ID'] = $post_ID;
wp_update_post($quick);
}
return $post_ID;
}
Related Posts:
- Adding a Taxonomy Filter to Admin List for a Custom Post Type?
- Implementing a CrunchBase.com Clone using WordPress?
- Custom media upload content for inserting custom post shortcode
- How to share category taxonomy with custom post type (The Event Calendar plugin)
- Is it possible to define a template for a custom post type within a plugin independent of the active theme?
- How to get a variable number of posts per post type on the main loop?
- WP_query parameters for date range
- Use a plugin to handle custom post types?
- Register Custom Post Type from Plugin
- Add .html extension to custom post type taxonomies
- How to load a new template page according to a particular URL?
- How to get the custom page get_permalink?
- Updating post meta for custom post types
- Template for custom post type shows all posts instead of just one
- Custom Post Type causes Page Not Found
- Frontend editing, Frontend user dashboard
- Override plugin with functions.php
- Should i delete the posts created by a plugin on uninstall?
- How does WP handle multiple matching rewrite rules?
- Saving Custom Post types and fields to a custom table
- Is it possible to use WordPress as an online portfolio for text content? What kind of theme would I look for?
- Building a store locator with google maps
- How to make wp_enqueue_style and wp_enqueue_script work only on custom post type
- How to create user groups and allow custom posts and plugin modify/access to specific group?
- Correct way to make meta box with more than one meta field secure
- I want to extend the current themes’ single.php to display the meta fields of my CPT
- How can I create a custom shortcode that will return a custom post type by ID?
- All of my custom posttypes are 404’ing
- more types plugin – display all post of post type on page
- When using Simple Fields plugin, how do I pull the information out of the database to display on a page?
- ‘No Results Found’ on single post for custom post type
- Making a Template for a CPT created by a plugin
- auto populate list of questions if user select a category xyz
- Adding CSS to custom post type admin page causes error
- ACF: post query, hide duplicate values [closed]
- Redirect to another page using contact form 7? [closed]
- Custom setup of wordpress comments that are displayed
- WordPress custom taxonomy not showing
- Using ACF default value to autoincrement a number field
- Amazon.com intergration with WordPress?
- Sticky option for custom post types without using custom fields or plugins
- Adding custom meta boxes to specified custom post type
- How do I make reusable content blocks for header and footer when using WordPress headless with another front-end?
- Preview with Custom Post Type Not Working
- How can I store data from custom fields to custom tables?
- 2 wordpress site same database
- How to Include Custom Post Content From Plugin
- Custom post type change excerpt more and excerpt length
- What hook can I use to modify custom post data before it is displayed on the page?
- Order posts of a custom post type by the event date using FT Calendar Plugin
- Creating teams of users in WordPress
- Custom Post Type template for homepage
- hardcoded wp pages/plugins problems
- How display specific category post to specific users?
- Best method of implementing compartmentalized custom post types on a multi-site network
- Need to edit author permissions | custom taxonomy
- Is it possible to pin a post in second position from top
- How to search post titles with whole words only, but not the exact word only?
- Save log for imports in WordPress database – options-table, custom post type or other place?
- Remove custom taxonomy name from the slug – Custom Post Type UI
- How to display emails as a post?
- Error in Fetching Custom Post Type parent Category URL (slug)
- Register PODS Custom Field with WPGraphQL [closed]
- Hidden permalink different from displayed permalink
- Adding custom post category to categories widget
- Custom Post Type with Sequence ID
- How to arrange custom posts in the backend/admin by custom taxonomy
- Adding LOAD MORE on a page
- custom post type get_posts() function not work
- Create multiple posts when a custom post is created
- how to convert frontpage.php to dynamic page?
- Cannot view Custom Post Type no matter what I try
- Creating custom “player-objects”
- Hide some portion on single.php base on author
- Displaying image from a repeatable group
- CPT-onomies CPT_TAXONOMY->get_terms extremely slow with 6K posts
- get recent 12 days post then random in wordpress
- Custom Post type plugin breaking the front page shows dashboard?
- What method should I use for a sidebar widget that reads latest posts?
- How can i do custom author list?
- WordPress User Frontend Editing Custom Fields
- How to list the categories by custom taxonomy created?
- Is a custom post type considred a plugin?
- Make a magic tag work with Custom Post Types
- How to laod wp_enqueue_style to another header i created my self
- Looking for a plugins for organization portal (Staff, Units, Departments)? [closed]
- Wrong block appender button showing
- Select posts from list and add them in a new list
- jet engine listing for every single taxonomy in post type [closed]
- Failed to update a post when I add a taxonomy to it
- Set the title of a custom post automatically by using info from custom fields?
- public custom posts not showing in my wordpress plugin
- plugin translation *.mo file not getting loaded for custom post
- How to add CPT in Elementor pro search template
- how to compare date meta value in jet smart filter Date query?
- My site has only one page, and users access my uploaded mp3 files from there – can I analyze access by song title?
- Tickera missing attendees – No attendees found
- How to check if the post exists in any of the categories?
- Load a custom post type template.html from a plugin
- How to make a page setting translatable in theme?