If the post content, title and excerpt are empty WordPress will prevent the insertion of the post. You can trick WordPress by first filtering the input array so empty values are set to something else, and then later resetting these values back to empty strings. This will bypass the standard check.
add_filter('pre_post_title', 'wpse28021_mask_empty');
add_filter('pre_post_content', 'wpse28021_mask_empty');
function wpse28021_mask_empty($value)
{
if ( empty($value) ) {
return ' ';
}
return $value;
}
add_filter('wp_insert_post_data', 'wpse28021_unmask_empty');
function wpse28021_unmask_empty($data)
{
if ( ' ' == $data['post_title'] ) {
$data['post_title'] = '';
}
if ( ' ' == $data['post_content'] ) {
$data['post_content'] = '';
}
return $data;
}
Related Posts:
- Function to execute when a post is moved to trash .
- How to add a “publish” link to the quick actions
- how “manage_posts_custom_column” action hook relate to “manage_${post_type}_columns” filter hook?
- the_posts filter been called multiple time
- How can i do something after head like adding a hook for after head but before post
- Create cron job without a plugin?
- How to generate numbers indistinguishable for the IDs of the posts
- Ajax posts filter by date, comments, top views, top likes
- Change post order random through out the entire WordPress
- Adding bootstrap classes to video shortcodes
- Prevent posts with certain post_meta to be edited
- How to check in functions.php if there is data in a WP_Query?
- Exists filter or action that change Add New Post link?
- the wp_post_update isn’t working all the time
- How to add a custom class attribute into code wrapper? [duplicate]
- Is it possible to completely replace a post with an action/filter?
- Filters do not work when there are multiple (one works)
- Modify upload directory to use post category slug in file path on multisite installation
- Add function to single blog post pages only
- Force the “Choose from the most used tags” meta box section to always be expanded
- Show the content that is after the excerpt using child theme
- Display Meta Values in Custom Filter – Admin Custom Posts
- How to allow users to post only in certain category and hide elements from edit page?
- How to filter my search in post if contains a word in title, content or excerpt?
- More then one menu items are assigned with “current-menu-item” class
- Update post_content everytime a custom post is opened in backend
- How to access $post from a callback function
- How to do set post permalinks using 6 digit random unique function?
- Can’t get buddypress notifications in front-end; why do I get this error?
- How do I display some posts fully on the homepage, and some as an excerpt only?
- Posts and Attachments with “Published” status in Search
- Send post id through ajax and get the post content back
- Display post x of y within category
- Force authors to Preview a post before publishing
- Set static page/post from another blog on same network
- WordPress Automatic Filename Changer
- How to allow visitors to filter posts by multiple taxonomies
- Copy post to separate database with “add_action(….)”
- WordPress class, using add_action to call member function does not work
- Redirect to another page using contact form 7? [closed]
- Order posts alphabetically: how to set order=asc in mysql query?
- Trying to alter the post_content through the_post
- Call Web Services on post first publish
- Create new custom post and post category of same name
- How to check if single.php has already called the_post_thumbnail function
- Override the WordPress core function wp_referer_field
- add to end of post in the loop with plugin
- Add filter to the end of the post
- Override a function defined in wp-includes/comment-template.php
- Get post content with all filters applied, knowing post id
- Change all author links in Blog roll
- disable Tab post on nav-menus page (Admin)
- What does WordPress do if I save a post without content/title? [duplicate]
- Is it possible to filter the main loop to exclude posts from a specific category?
- Every second post different class in blog view
- Format latest/newest post differently
- is_page Funtion for Posts ?
- query post limits
- Post type no single page
- Get post meta retrieving wrong value
- Adding a user’s ID behind the tag ref link address
- The_excerpt() doesn’t parse – how to change that?
- Divs appearing everywhere in post content
- How to only publish posts with image in it
- Modify posts listing at back end
- Isn’t the way posts are displayed very unefficient?
- Filtering posts on Post Administration Page by Week Number instead of by Month
- Add custom text automatically on each post
- Call to undefined function is_home() or any conditional tags
- Change the default blog post post attribute template name from “default template” to something else
- Hook for changing excerpt content when excerpt not set
- Is it possible to add a shortcode below post title?
- login_headertitle is deprecated since version 5.2.0
- restrict incrementation of post vies count when refreshing the page
- Post filtering is returning blank page
- Defined function isn’t showed on page
- Update post meta within save_post action
- WordPress 302 Redirect to Random Product/Post/Page
- Automatically set post_parent value
- Updating permalink structure using ‘post_link’ filter results in 404 error for posts
- Getting Whitescreen when publishing a post [closed]
- Using system date format
- How include css class based on post ( in loop ) slug?
- Get post by tag
- Add code to a specific post’s content
- Related Posts function not working
- the_content() Not Grabbing All Content
- Un-highlight Blog Menu Item when Category Menu Item is Selected
- Restrict displaying posts to the poster itself (in Back-end)
- Insert Content Before div#main from the functions.php File
- Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )
- Related Posts: Changing Function For Posts Per Page
- Query function not executed between element [closed]
- Optimize CPT-function with a loop
- saving/reading custom field value does not work – no value gets POSTed
- Same post appears in related Posts?
- Internal linking to posts permalink fail because of spaces and stripe at postname
- Have h2 tag not show up if there are no blog posts
- WordPress as CMS: How to manage/handle images assigned to a post as full-sized background images in a slideshow?
- changing parent_id on post