3
07/11/2024 9:38 am
Argomento iniziale
In WordPress, voglio creare un semplice plugin che modifichi i titoli dei post del blog.
Come posso farlo?
Grazie!
1 risposta
2
07/11/2024 9:39 am
Eccone una:
<?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' );
Cambia anche i titoli nell'area di amministrazione.
Se non si desidera modificare il titolo nell'area di amministrazione, utilizzare questo:
/*
* 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' );
