Awesome, thank you so much! It works fine. If I want to make sure this filter is not overwritten when I update the theme, I should put this in a child theme right?
And how should the code look if I want this for pages as well, when the code for posts look like this
.. if ( is_singular( ‘post’ ) ) {
return ‘https://example.com/’ . $post->post_name; …