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)
- Changing the post date and time with function
- Get current post id in functions.php
- How to validate XML-RPC post creation and cancel when needed?
- Dynamically add id to heading tags
- How to call function within a page/post, to dynamically generate content?
- Why is wordpress removing some unicode characters (e.g. some emojis) when I save my post?
- Convert hyphen to underscore in permalinks
- Count singular post views automatically
- Guest Author – How to modify my custom function code if the guest author URL will follow a particular pattern/format?
- How to get new post URL?
- Force update all posts in custom post type, no content changes
- Disable REST API for a user ROLE
- Add confirmation popup on “Move to Trash”
- How to filter content post only on save
- $post object is null
- How to get Custom Post ID by adding filter to child theme’s function
- How to update feed only 2-3 times a week (for Feedburner email)?
- How to change the page break URL from ../post/2 to …/post/page2/
- How can I list random authors from current post category?
- Amend wordpress password function
- Getting current post ID in functions.php
- How to retrieve the postID in a “image_send_to_editor” hook function?
- Load post attached images on a single page site with fancybox
- Exclude category from
- Setting posts_per_page for taxonomy term template
- use wpml_post_language_details function other plugin based on $post->ID [closed]
- Add filter by custom field to block of posts
- Default to ‘all’ view on the ‘edit-post’ screen for authors
- 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?
- Send post id through ajax and get the post content back
- Set static page/post from another blog on same network
- How to allow visitors to filter posts by multiple taxonomies
- Create new custom post and post category of same name
- Override the WordPress core function wp_referer_field
- Override a function defined in wp-includes/comment-template.php
- Change all author links in Blog roll
- Is it possible to filter the main loop to exclude posts from a specific category?
- Format latest/newest post differently
- is_page Funtion for Posts ?
- How to only publish posts with image in it
- Modify posts listing at back end
- Hook for changing excerpt content when excerpt not set
- login_headertitle is deprecated since version 5.2.0
- Using system date format
- How include css class based on post ( in loop ) slug?
- Restrict displaying posts to the poster itself (in Back-end)
- saving/reading custom field value does not work – no value gets POSTed
- Internal linking to posts permalink fail because of spaces and stripe at postname
- changing parent_id on post
- Actions to use when flushing cache (when posts are added / deleted / modified)
- How to implement a WordPress comments function?
- How to add content above footer in posts from specific category
- can’t modify post title using the_posts filter
- shortcode // get posts by ids
- Using AJAX to filter posts without refreshing page
- Find most used words in post titles
- $post->post_content empty while all other properties are correct
- How Do I Unhook This Parent Theme Function?
- Dropdown Select Post Filter
- show only one category and filter by tag
- AJAX load more posts not using correct category and repeating the same few posts
- Which method is more correct for removing WooCommerce Extensions menu item?
- Prevent WordPress from putting around specific element
- filter buddypress users posts by user ‘xprofile’ custom fields
- Grab meta data before post is saved
- How to correctly escape data
- Printable Page with all Posts from Tag
- Hide Admin posts & pages in Dashboard
- How to get the postID inside ‘content_save_pre’? Other hook?
- Filter question list on substring of metavalue
- How to change number of posts shown on homepage vs other pages?
- Get results from the main wp_query
- Settings in functions.php used by a plugin
- Keep post format class with isotope filter
- Custom filter on all post page (admin backend)
- How to use in_category?
- How can I create a menu items from meta box based on users input
- List direct children of page
- Display a custom field rating system in the front end
- Ajax calls in wordpress
- Add custom PHP (no-SQL) filter to WP_query
- How to use shortcode to get the second to newest post?