function snipjar_publish_min_words( $post_id, $post ) {
// Edit the line below to set the desired minimum number of words.
$word_count = 100;
if ( str_word_count( $post->post_content ) < $word_count ) {
wp_die(
sprintf(
// Translators: placeholder adds the minimum number of words.
esc_html__( 'The post content is below the minimum word count. Your post needs to have at least %d words to be published.' ),
absint( $word_count )
)
);
}
}
add_action( 'publish_post', 'snipjar_publish_min_words', 9, 2 );
Content
Show post thumbnails in RSS Feed
function snipjar_feed_post_thumbnail($content) {
global $post;
if(has_post_thumbnail($post->ID)) {
$content = '' . $content;
}
return $content;
}
add_filter('the_excerpt_rss', 'snipjar_feed_post_thumbnail');
add_filter('the_content_feed', 'snipjar_feed_post_thumbnail');
Disable automatically deleting trashed posts
Do not let WordPress delete trashed posts after 30 days.
add_action( 'init', function() {
remove_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );
} );
Change excerpt length
add_filter(
'excerpt_length',
function ( $length ) {
// Number of words to display in the excerpt.
return 40;
},
500
);
Decrease Auto-Save interval
if ( ! defined( 'AUTOSAVE_INTERVAL' ) ) {
// Change 10 to the number of minutes you want to use.
define( 'AUTOSAVE_INTERVAL', 10 * MINUTE_IN_SECONDS );
}
Limit the number of post revisions
add_filter( 'wp_revisions_to_keep', function( $limit ) {
return 10;
} );
Set a minimum word count for posts
function wpcode_snippet_publish_min_words( $post_id, $post ) {
$word_count = 100;
if ( str_word_count( $post->post_content ) < $word_count ) {
wp_die(
sprintf(
// Translators: placeholder adds the minimum number of words.
esc_html__( 'The post content is below the minimum word count. Your post needs to have at least %d words to be published.' ),
absint( $word_count )
)
);
}
}
add_action( 'publish_post', 'wpcode_snippet_publish_min_words', 9, 2 );