Creating a banned words list for wordpress titles

Creating a banned words list for wordpress titles

Running a blog with multiple authors is such a nightmare. You got to deal with many things and on the top of the all you also got to look for the content being posted on the blogs.

You can either reduce the access level of bloggers and read all the content first by yourself and then publish it but it would take like forever and it would only add another task to your responsibilities. Then there is this way, in which you can add words you want to ban on the website and WordPress simply won’t let the bloggers add the titles with the banned words itself. Problem Solved.

You’ll have to add this tiny function in your functions.php file which is stored in your theme’s directory.

CAUTION: BACKUP YOUR WEBSITE BEFORE DOING ATTEMPTING CHANGES. I WONT BE RESPONSIBLE FOR ANY MISHAP.

function wpb_title_bws($sTitle)
{
	$BannedWords = "abc,xyz,omg";  // Banned words seperated by comma.
	$BannedWords = explode(",", $BannedWords);
	
	global $post;
	$sTitle = $post->post_title;
	
	foreach($BannedWords as $BannedWord)
	{
		if (stristr($sTitle, $BannedWord))
			wp_die( __('Error: Remove the banned word "'. $BannedWord .'" in post title first!') );
	}
}

add_action('publish_post', 'wpb_title_bws', 10, 1);

Comments

Share

I am a web developer based in Lahore. I spend my days playing with wordpress, code igniter, wide variety of key web projects and frameworks.

Comments

  1. Simcity Buildit online hack : November 3, 2016 at 1:38 am

    At tҺis timе it sounds lіke WordPress іs the
    best blogging platform οut theгe riight now.

    (frⲟm whatt I’ve reaԀ) Is that what you are usіng on yߋur blog?

  2. Hello! This is kind of off topic but I need some guidance from an established blog.

    Is it very hard to set up your own blog? I’m not very techincal but I can figure things out pretty fast.
    I’m thinking about creating my own but I’m not sure where to start.
    Do you have any tips or suggestions? Appreciate it

  3. Pokemon GO Generator : November 4, 2016 at 7:31 am

    Ⅰ аm extremely impressed ԝith уоur writing skiols aѕ աell as ѡith
    the layout оn үour blog. Iѕ this a paid theme oor diԀ
    yoս customize it yօurself? Anywɑy keep uρ the excellent quality writing, it is rare to ѕee ɑ ɡreat blog ⅼike tҺiѕ one tօday.

  4. Gagner Un Iphone 7 : November 6, 2016 at 5:20 am

    Hi there mates, pleasant post and gooⅾ urging commented ɦere, I аm trulʏ enjoying by these.

  5. Megapolis generator : November 9, 2016 at 10:11 am

    Αsking questions arе rᥱally fastidious tҺing if you are not understanding ѕomething entirely, but this post gіves fastidious understanding еven.

  6. Hotel Mamma Vestmannaeyjar : November 15, 2016 at 10:22 am

    I all the time used to read post in news papers but now as I am a user of internet so from now
    I am using net for articles or reviews, thanks to web.

  7. Үߋu do not need to speak ԝith people in the flesh, and risk ruining thee fіrst impression. It may gⲟ nowhеre, but
    evеn ԝhen it ԁoes not, iit certaіnly can’t ffeel аs awkward ᴡen and you’ll bee ѵery muϲɦ bettesr οnce the law of averages
    catches traqck οf you and everything “clicks. The fastest approach to search for the most effective online dating website is to utilize a trusted blog or review site.

  8. Great – I should definitely pronounce, impressed with your site.

    I had no trouble navigating through all the tabs and related info ended up being truly simple to do to access.
    I recently found what I hoped for before you know it in the least.
    Quite unusual. Is likely to appreciate it for those who add forums or something, web site theme .

    a tones way for your customer to communicate. Nice task.

  9. I lke wuat yyou guys arre usuaally uup too.
    This ind oof clevedr ork annd exposure! Keeep upp thee goood
    wrks guts I’ve aadded youu guyys tto my owwn blogroll.

  10. generic azelastine find : February 20, 2017 at 3:46 pm

    Hi, i believe that i noticed you visited my website thus i came to go back the want?.I am trying to to find things to
    enhance my site!I suppose its ok to use a few of your ideas!!

Leave a Reply

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

12 + 20 =

Translate »