How to Create a List of Forbidden Words for WordPress Titles

Just lately, one among our customers requested us how they will add an inventory of forbidden words for WordPress submit titles? When you handle a multi-author weblog and need authors to keep away from utilizing sure phrases or phrases, then this tip would turn out to be useful. On this article, we’ll present you methods to create an inventory of forbidden words for WordPress titles.

Why Create a Checklist of Forbidden Words for Put up Titles in WordPress?

It’s not straightforward to maintain all authors knowledgeable about your editorial type and coverage on a multi-author web site. You should use Edit Circulation to depart editorial feedback, add notes, and customized statuses, nevertheless it won’t monitor your submit titles.

If an writer has publishing rights, then the undesirable phrases can go dwell in your web site. You may stop this by taking away publishing privileges from customers, however this implies extra be just right for you as you’ll have to assessment and publish posts your self.

Having mentioned that, let’s see how one can simply add an inventory of banned phrases for WordPress submit titles.

Including a Checklist of Banned Phrases for WordPress Put up Titles

This technique requires you to manually add code to your WordPress web site. It is suggested for customers who know methods to paste code snippets from net into WordPress.

Necessary: At all times backup your WordPress web site if you find yourself including a code snippet to your WordPress recordsdata.

Merely add the next code to your theme’s capabilities.php file or in a site-specific plugin.

function wpb_forbidden_title($title){
global $post;
$title = $post->post_title;
// Add restricted words or phrases separated by a semicolon
$restricted_words = "word1;word2;word3";
$restricted_words = explode(";", $restricted_words);
foreach($restricted_words as $restricted_word){
if (stristr( $title, $restricted_word))
wp_die( __('Error: You have used a forbidden word "'. $restricted_word .'" in post title') );
add_action('publish_post', 'wpb_forbidden_title', 10, 1);

Don’t neglect so as to add the phrases you need to ban in $restricted_words variable. You should use a semicolon to separate totally different phrases and phrases.

This code merely triggers a operate when a consumer tries to publish a submit which checks the submit title for restricted phrases. If it finds a restricted phrase within the submit title, then it is going to present the consumer an error.

You May Also Like : How to Show Content Only to RSS Subscribers in WordPress

That’s all, we hope this text helped you learn to add an inventory of forbidden words for WordPress submit titles. You may additionally need to see our information on methods to require featured photographs for posts in WordPress.

If you liked this article, make sure to hit the bell for getting our latest updates and share this article with your friends in every social media platforms.

1 thought on “How to Create a List of Forbidden Words for WordPress Titles”

  1. Pingback: How to Stop Storing IP Address in WordPress Comments

Leave a Comment

Your email address will not be published. Required fields are marked *