Since you’re defining $post_type
, why not just use it instead?
function wpbeginner_titlerss($content) {
global $wp_query;
$post_type = $wp_query->post_type;
if( $post_type == 'essays' ) {
$content="Essay: ".$content;
}
elseif ( $post_type == 'gallery' ){
$content="Gallery: ".$content;
}
elseif ( $post_type == 'games' ){
$content="Game: ".$content;
}
else {
$content = $content;
}
return $content;
}
add_filter( 'the_title_rss', 'wpbeginner_titlerss' );
(This assumes you have created custom post types, essays
, gallery
, and games
.)