3
07/11/2024 9:38 am
Início do tópico
No WordPress, pretendo criar um plugin simples que modifica os títulos das mensagens do blogue.
Como é que posso fazer isto?
Obrigado!
1 Resposta
2
07/11/2024 9:39 am
Aqui está uma:
<?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' );
Também altera os títulos na área de administração.
Se não pretender alterar o título na área de administração, utilize isto:
/*
* 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' );
