Site icon Hip-Hop Website Design and Development

Change post title but not in widgets/menu/etc

I have searched and searched, and can’t find what I’m doing wrong.

I am using a shortcode and custom field to edit the title of a post by adding an audio player right behind the title. At first I was using "is_single" and that was working, however it changes the title in widgets too.

So I tried to use "in_the_loop" in the code, but then nothing shows up, so I’m clearly doing something wrong. This may be because I’m piecing together multiple pieces of code I found to get this working.

add_filter( 'the_title', 'se385007_title_filter' , 20, 2  );
function se385007_title_filter( $title, $post_id ) 
{
    if ( in_the_loop()){

    $termp = get_post_meta($post_id, "term_pronunciation", true);
        if($termp != ""){ $title .= "  [sc_embed_player fileurl="" . $termp . ""]"; }
        
    }
    return do_shortcode( $title ); 
    
}