Hi @toplisek, what error exactly are you getting? PHP does indeed allow return statements outside functions, in which case the execution of the entire current script is getting stopped (which however might certainly cause your code not to run as intended, or even induce other errors).
In this code, theme_slug_setup is a custom function that calls add_theme_support( 'title-tag' ) to enable support for the title tag. This function is hooked into the after_setup_theme action, which is triggered after the theme is loaded.
After adding this code to your functions.php file, WordPress will automatically manage the title tag for your theme, and you should see the correct title tags in your pages.
Remember to replace theme_slug_setup with a unique function name that matches your theme’s naming conventions to avoid conflicts with other themes or plugins.