str_replace not preserving whitespace

  1. Did you clear cache after making changes with trim()?

  2. Try with: str_replace( trim( $parent->name ), $link, $intro_text );

  3. Are you sure that the term is Upbeat Electronic music and not UpbeatElectronic music?
    Try with this to be sure:

    str_replace( trim( $parent->name ), ' ' . $link, $intro_text );