dongshen2903
2017-04-18 08:40如何在wordpress帖子中设置最小字数
I am planning to create a code filter and set a minimum word count in saving/submitting the wordpress post. I tried this code.
function minWord($content)
{
global $post;
$content = $post->post_content;
if (str_word_count($content) < 300 ) //set this to the minimum number of words
wp_die( __('Error: your post is below the minimum word count. It needs to be longer than 300 words.') );
}
add_action('publish_post', 'minWord');
but the issue, when I input < 300
words the post
still saves it on the database. My question now is what should I do that if the content will have < 300
words it won't save to the database?
- 点赞
- 回答
- 收藏
- 复制链接分享
2条回答
为你推荐
- 如何在wordpress帖子中设置最小字数
- wordpress
- php
- 2个回答