How to Override Page Template if URL matches query?

I have 4 Page Templates that my theme uses for all the pages – Default Template, Template One, Template Two and Template Three.

When the relevant Page Template is selected, it loads an Advanced Custom Fields Group which enables the user to build/design a specific page – i.e. Template Two is for an F.A.Q page, Template Three is for a photo gallery.

I have added 4 new links in the Admin Sidebar which directs the user to the “Add New Page” URL – “post-new.php?post_type=page”. For each link, it appends the name of the template at the end of the URL i.e. “post-new.php?post_type=page&template=three“.

I would like to have the Edit Page load the correct Page Template depending on the template dictated in the URL – “template=three” would load “Template Three”.

I am able to do a check with the URL and form an if statement with the below code —

I am struggling with how to hook this into functions.php. I have tried editing the below ( https://wordpress.stackexchange.com/a/231503/182411 ) but it isn’t working:

Xin chào các bạn và quý Thầy Cô. Hãy nhập từ khóa mình muốn vào ô tìm kiếm trên Website để tìm kiếm mọi thứ hoặc trên google các bạn hãy nhập từ khóa + dethihsg247.com để tìm kiếm các bài viết của chúng tôi nhé.
  • Hiện tại chúng tôi có hơn 25 nghìn bài văn mẫu các thể loại.
  • Kho tài liệu, đề thi học sinh giỏi các lớp vô cùng phong phú.
  • Mỗi ngày cập nhật hơn 100 đề thi chất lượng từ các website bán tài liệu lớn.

Tải đề thi VIP với giá siêu rẻ tại Vip.Dethihsg247.Com