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
- How to add a post page from a button without reloading
- Is This Code Efficient – Or is there a better way?
- get post types and plugin order
- Confused about Custom Post Types
- get parent content inside child posts
- Add an Outside Wrapper to my Header and Make it Full Width
- page template for custom post type
- 3 random images from custom post type, each in a div with a diffrent class
- Sortable column containing numeric values for Custom Post Type at WordPress Backend
- How to get specific post meta by title or id
- Listing all post from different custom post type for the logged in user
- Trouble with pagination
- get_category_link() for custom post type does not include custom slug rewrite?
- Page Template Dropdown For Custom Post Types
- Why are some of my custom posts not showing up on my page?
- How to list tags from custom post type attachments?
- How to add editable/dynamic values to dropdown of a Custom Post Type Meta Box
- How to concatenate two separate colums into one?
- make permalink go to a custom single.php file
- Custom Meta Box Causing Error: “Are you sure you want to do this? Please try again.”
- Why content coming from single?
- Two column layout with alphabetical ordering
- Make custom post meta sortable front end
- Delete a custom post function value
- Strip Characters From Tag Name
- custom post type archive page has 404 error even though has_archive is true
- $wpdb->get_col and ORDER BY?
- How to Display Posts From Category Within a Custom Taxonomy?
- Publish and save specific postmeta to a filtered post_type
- Make homepage the newest post of a custom post type
- how to associate several authors to a custom post type
- Pagination 404 on Index with custom query
- Add “Select All” to custom taxonomy
- post-per-page and offset not working
- Gravity forms multiple posts generated by one form [closed]
- Why are previous_post_link/next_post_link skipping some posts?
- Add tags to custom post type without menu link
- Display custom taxonomy on my custom post type
- List Categories (wp_terms) and count posts
- Post loop count is not in order
- Gravity forms how to display list of submitters on the post submitted page [closed]
- Add Previous/Next Buttons to CPT Single Pages Only