admin管理员组文章数量:1290926
I'm using IFTTT to post images from a subreddit to my WordPress site, and then WordPress shares those images with their post titles on multiple social sites.
The problem is, IFTTT publishes blank posts on WordPress sometimes. They only have a title but no images. Now the plugin I use for sharing the posts published by IFTTT can't recognize empty posts, and it shares only their title on other social media sites since there is no image.
So my only solution is to auto delete empty WordPress posts. Is there any script or plugin to do it?
Please let me know. Thanks
I'm using IFTTT to post images from a subreddit to my WordPress site, and then WordPress shares those images with their post titles on multiple social sites.
The problem is, IFTTT publishes blank posts on WordPress sometimes. They only have a title but no images. Now the plugin I use for sharing the posts published by IFTTT can't recognize empty posts, and it shares only their title on other social media sites since there is no image.
So my only solution is to auto delete empty WordPress posts. Is there any script or plugin to do it?
Please let me know. Thanks
Share Improve this question asked Jun 10, 2021 at 10:02 heyitsriteshheyitsritesh 32 bronze badges1 Answer
Reset to default 0You want to write a wp_insert_post_empty_content filter.
WordPress will already try and reject empty posts:
$maybe_empty = 'attachment' !== $post_type
&& ! $post_content && ! $post_title && ! $post_excerpt
&& post_type_supports( $post_type, 'editor' )
&& post_type_supports( $post_type, 'title' )
&& post_type_supports( $post_type, 'excerpt' );
but I guess that logic isn't catching your posts here. So you'll need to work out what your empty posts look like specifically and catch them too:
function wpse390344_empty_posts_filter( $empty, $postarr ) {
if ( ! $empty ) {
// TODO: look at $postarr - see wp_insert_post() documentation for format
// and decide if this is an empty post you want to reject.
// If it is, return true.
}
return $empty;
}
add_filter( 'wp_insert_post_empty_content', 'wpse390344_empty_posts_filter', 10, 2 );
本文标签: pluginsAuto delete empty posts
版权声明:本文标题:plugins - Auto delete empty posts 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741512814a2382705.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论