The problem is global $post
.
As @Pieter suggested global $post
object can be alter anytime with some other plugin or code. Menu items are effected because global $post
does not contain the correct object.
Instead of $post
, the_title
filter also provide you ID of current post in action, so use it in this way
function append_album_review_to_title( $title, $id ) {
if ( get_post_type( $id ) == 'album_review' ){
return 'Album Review: ' . $title;
} else {
return $title;
}
}
add_filter('the_title', 'append_album_review_to_title', 10, 2);