I want a simple WordPress plugin to modify blog post titles

  

3
Topic starter

In WordPress, I want to create a simple plugin that modifies the titles of blog posts.

How can I do this?

Thanks!

1 Answer
2

Here's one:

<?php
/*
 * Plugin Name: Modify Blog Post Titles
 * Author: Your Name
 * Author URI: Your URL
 * Description: Creating a Simple WordPress Plugin to Modify Blog Post Titles
 * */

/* Changing the title of a blog post */
function change_the_title( $title ) {
	return "The title of " . $title . "has been changed";
}

add_filter( 'the_title', 'change_the_title' );

It changes the titles in the admin area as well. 

If you do not want to change the title in the admin area use this: 

/*
 * Plugin Name: Modify Blog Post Titles
 * Author: Your Name
 * Author URI: Your URL
 * Description: Creating a Simple WordPress Plugin to Modify Blog Post Titles
 * */

/* Changing the title of a blog post */
function change_the_title( $title ) {
	if ( is_admin() ) {
		return $title;
	}
	return "The title of " . $title . "has been changed";
}

add_filter( 'the_title', 'change_the_title' );
Share: