Thank you so much for trying to help. I used one of your files and it works as it should now.
The only problem left is duplicate meta data when I use Yoast SEO plugin. Meta URL, TYPE, TITLE and DESCRIPTION are duplicate. Have you encountered this problem?