There are many great code snippets in their Gitlab. You might find more on their…
Changing the page title in WordPress
//CHANGE POST TITLE
function custom_modify_title( $title, $id = null ) {
return 'CUSTOM '.$title;
}
add_filter( 'wp_title', 'custom_modify_title', 10, 2 );
add_filter( 'the_title', 'custom_modify_title', 10, 2 );
Change depending on post type
//CHANGE POST TITLE
add_filter('the_title','custom_modify_title2');
function custom_modify_title2($data){
global $post;
if (get_post_type( $post->ID ) == "expertenprofil") {
return get_post_meta($post->ID, 'wpcf-anonymer-titel', true);
} else {
return;
}
}
Changing document title
//CHANGE POST TITLE
add_filter( 'pre_get_document_title', 'change_profile_title' );
function change_profile_title () {
global $post;
if (get_post_type( $post->ID ) == "expertenprofil") {
return get_post_meta($post->ID, 'wpcf-anonymer-titel', true);
} else if (get_post_type( $post->ID ) == "bewertung") {
//bewertung nutzt sowieso anonymen titel daher brauche ich das nicht
// get the id of the post
/*
$the_id = $post->ID;
// get the custom taxonomy term name
$source_archive_name = wp_strip_all_tags( get_the_term_list( $the_id, 'bundesland', '', ' / ' ) );
// read all the data for the term into an array
$term_data = get_term_by( 'name', $source_archive_name, 'bundesland', ARRAY_A );
// pull the term id out of the array
$term = get_term( $term_data["term_id"], 'bundesland' );
$bundesland = $term->name;
return "Einigungsstelle in ". $bundesland;
*/
//return $post->post_title;
return;
} else {
return;
}
}
Dieser Beitrag hat 0 Kommentare