Yoast Sitemap has my subdomain, I want sitemap needs to be generate by my primary domain

  • Description: - There are many thread avaibale but none of them is easy to understand for beginner, so i am creating thread for siteamp issue everyone is facing.
    Problem :- Wordpress in Decoupled Mode serve from subdomain for example cms.mydomain.com
    and website is serving from mydomain.com

solution-available :- people suggests use different sitemap plugins, which is good for beginner but large organization running multiple webites heavily dependent on yoast plugin , they are paying for the premuim version . they can chnage the plugin
many other solution were like add this block of code in your functions.php, its not working
please provide the full path of file where code needs to be added at bottom of file or at beginning

Please provide answere here so everyone can get help from community

lets make frontity simple again !