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
- Permalinks: custom post type -> custom taxonomy -> post
- How to Add Tags to Custom Post Type?
- Efficient Taxonomy Intersection
- How to create a wp_query that contains both meta_query and tax_query
- Display custom post type and custom fields within a Bootstrap Carousel
- Notice: map_meta_cap was called incorrectly
- Archive page…limiting posts per page
- Seperating Custom Post Search Results
- Use WP_Query object inside a function
- How to have a custom URL structure for a custom post type?
- Custom permalinks – post type – hierarchical taxonomy’s
- How do I create new content pages for my Custom Post Type?
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- Taxonomy list. Order by a specific custom post type count
- Rewrite CPT slug with two taxonomy slug instead of one
- Custom Taxonomy breaking pages permalinks
- Frontend Form for Custom Post Type
- How to show custom post template from single page?
- Custom query shows custom post types in trash
- How to create new category for custom post type?
- How to clone the “Projects” Custom Post type in Divi theme
- Remove url rewrites for registered taxonomies
- Not Able to Get Custom Post Type Gallery Images URL
- Building a Treatments Page, What Do I Use?
- Migrating a taxonomy’s tags to the native category
- filter by custom taxonomy using ajax
- How to get the current category with custom posts
- Modify Posts from Custom_Post_Type within the plugin
- Custom Post Types and Complex Content Hierarchy
- How do I “trash” a custom post type post while logged in as Admin
- Pagenavi Plugin and Custom Post Type – Multipage results
- How to display custom taxonomy term specific post?
- Remove Header and style.css from Specific Post template
- How to remove default modules on single event page on Modern Events Calendar
- Show posts from WP Custom Post Type selected from a field in a metabox
- WordPress post not executing shortcode until updated
- Keep custom read more link on the same line as excerpt text
- Custom Post Type
- Can I create a taxonomy term that mirrors the name of a new custom post?
- Ads below footer
- Rewrite for custom type and custom taxonomy
- Show custom post along with default post
- Where do I insert to? [closed]