Last active
January 19, 2016 21:28
-
-
Save rugor/5417979 to your computer and use it in GitHub Desktop.
PHP: Wordpress functions.php specify number of words in post title #rugor #st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Maximum 10 Words in Post Title !!! | |
function maxWord($title){ | |
global $post; | |
$title = $post->post_title; | |
if (str_word_count($title) >= 10 ) //set this to the maximum number of words | |
wp_die( __('Error: your post title is over the maximum word count.') ); | |
} | |
add_action('publish_post', 'maxWord'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment