3
07/11/2024 9:38 am
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
07/11/2024 9:39 am
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' );