3
07/11/2024 9:38 a.m.
Themenstarter
In WordPress möchte ich ein einfaches Plugin erstellen, das die Titel von Blogbeiträgen ändert.
Wie kann ich das tun?
Danke!
1 Antwort
2
07/11/2024 9:39 a.m.
Hier ist eine:
<?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' );
Es ändert auch die Titel im Adminbereich.
Wenn Sie den Titel nicht im Verwaltungsbereich ändern möchten, verwenden Sie diese Option:
/*
* 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' );
