Ah, I solved it! The problem was that outside of the admin panel WP does not load wp-admin. The solution was to add
if (!is_admin()) {
require_once(ABSPATH . 'wp-admin/includes/post.php');
}
Now it works like a charm! 🙂
Related Posts:
- Get post ID from wp_insert_post()
- WP insert post and custom taxonomy
- How do I programmatically add items of content to a custom post type?
- Not Able to Insert Taxonomy Term Using wp_insert_post()
- How I upload, save and set a featured image from my frontend?
- Trying to save custom post type from frontend partially working
- wp_insert_post custom taxonomy
- Assign category to front end post
- How can I programmatically save data into custom fields that contain serialized data?
- What hook should be used to programmatically create a post only when master post is updated?
- WordPress tax_input only if logged in
- Programmatically adding posts
- Is it possible to create a post using a metabox?
- How Can I Set the Post Author of a Post I Just Created With PHP?
- How to auto increment post title & post slug field?
- Auto-generated posts not showing in backend (but being counted!)
- wp_insert_post generates endless posts
- Update CPT post meta with update_post_meta and cron job
- Automatically update custom field in all posts of a custom post type
- create parent post using wp_insert_post
- How to checked selected category checkbox when my custom post inserted from frontend
- Post author for revision not being set on update/insert
- Add CPT values to Database
- Why cant I add a custom post type to a custom taxonomy?
- wp_insert_post wrong post type [closed]
- Programatically inserted posts not showing in Posts Table
- Is it possible to add posts and images (auto resize) for custom post types with a script?
- Update post if exist from PHP
- WordPress hook which triggers on post import
- How to handle new post from API request?
- How to handle this specific case of custom post type?
- insert image with custom post type
- importing table data to custom post type
- How can I get some of a posts meta data whilst it is still inserting?
- Set up a WP Cron scheduled event to update calculated ACF field
- See if the email exists or not
- WP_Insert_Post creating duplicate posts when logged in
- wp_insert_post from XML feed only inserting first post
- What is the correct way that when creating a custom post type assign values to custom fields created with pods framework?
- How do I find out which (page) template file my custom child post is looking for?
- wp_insert_post deleting previous post custom meta
- wp delete duplicate entries of custom post types every 15 minutes
- Published page but it is page not found
- How to insert post 6 times after user register like ask.fm
- wp_insert_post() creates duplicates with ‘post_status’ => ‘publish’
- automatic creation of custom post type articles
- Submitting custom post from frontend,jQuery ajax, and custom validation – can’t find proper place to insert wp_insert_post()
- UPDATED: Save a custom_field value when automatically creating a post using wp_insert_post
- Generate slug and meta data if meta field is empty
- Add a image to a post published on a CPT from the front-end
- wordpress form processing to custom post type not working
- install.php Custom Taxonomy Term not being added to custom post
- Omitted Content After Post-Publish Insertion
- Is this the correct way to add post-slug input field?
- wp_insert_post not working for custom post type?
- After wp_insert_post() custom post type does not show in the admin
- Using wp_insert_post to create custom posts with ACF image field
- Add a post when another post type is inserting
- Slug Formatting : Acceptable Characters?
- WordPress “Loop” with large set of results
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- Custom Search | Wrong output & question
- Interesting Custom Post Type Slug with Taxonomy and Custom Field
- Custom edit post column – category not showing
- Custom Post Type post ordering not working
- Pagination links not showing on custom post type admin list
- Custom permalink – append taxonomy name and term name at the end of permalink
- Custom Role for CPT Only
- Pull in custom content types into page template
- Assigning the same custom meta box to multiple post types
- Custom Post Status Transition Issues With Get Post Meta
- Custom post type not displaying all entries
- Listing tags from a custom post type
- Custom post URL 404 error
- Add Custom Post Type as top level menu item for a custom page
- How do I set a custom page template for a custom post type?
- Limit the Title Length on Custom Post Type Archive Page to a Set Number of Characters
- Custom Post Type Category On Admin
- Move content between custom post types
- Pods CMS: How to add custom column to Adnvanced Content Type
- How check if a post is saved from backend or frontend?
- Exclude Custom post type from /blog page
- Creating a “glossary” of WordPress posts of a specific post type
- How to filter url on post submission?
- Custom Plugin – Query CPT – Display Results
- Control over custom post types on a specific page
- How to display the post using a shortcode in WordPress?
- How do you create pillar content pages?
- dynamic vue widget inside custom post
- Get meta values from parent post and save in child post
- how to use two permalinks for one custom post type based on categories
- Complex strcuture as CPT or taxonomy for use in woocommerce product variations [closed]
- Custom post type archive pagination with HTML5Blank theme?
- Reading csv from specific directory and insert it to custom post type (cron job)
- Problems with a custom meta_box
- Show custom posts with a specific “custom TAXONOMY slug” on startpage
- How to make a single Menu Item call another Mega Menu for Custom Post Types and Custom Taxonomies?
- Default WordPress Query for a Specific Custom Post Type URL
- Custom post type pagination conflict result in 404
- Generate list of posts on a page, but fill shortcode values from ACF fields on that page