Skip to content

WordPress restrict a specific word from post title?

    function titleRestrictionFilter($title){
        global $post;
        $title = $post->post_title;
        $restrictedWord = "forbidden";
        if (stristr( $title, $restrictedWord))
        wp_die( __('Error: This title is containing restricted word') );
    }
    add_action('publish_post', 'titleRestrictionFilter');
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments