I need to programmatically create a page that uses a specific/custom template as defined programmatically. Both the page and template are created/used by my plugin.
The plugin files include a page template. The plugin code (with a button press) will create the page ('mycustompage') (similar to the technique here Add custom template page programmatically ).
But I need to specify the template used by that page. The page has to use the template in my_plugin_folder/templates/mytemplate.php . The template cannot be in the current theme folder structure.
Once the page is created, then the plugin will open a new tab with www.example.com/mycustompage (assume plugin code creates a unique/unused page name).
How do I specify the template that will be used by the programmatically-created-page when I call the created page (as in www.example.com/mycustompage ? And, the template to use is not in the current theme folder.
Added
Note that I am creating HTML code 'manually' by using The Loop to output post content. The HTML code is not being displayed on a WP page. So there is no WP JS used that converts emoji HMTL characters into the emoji graphic.
If I was to create a Page that uses a simple template to display only posts (the template does not use wp_header/sidebars/footers, etc), and then display that page, the emoji are shown as graphics in the browser. If I copy that page (in the browser) and paste that into Word, the graphics are in Word -- because they are on the browser page.
But, I am creating all of the HTML (of the post content) with PHP code. And I haven't found a good way to convert emoji HTML code to emoji graphics.
So, I figured that (instead of creating HTML code for the entire page) using a simple template that is used by a Page that I create programatically would allow WP to use that Page (and all posts content) that would show emoji graphics. But templates are normally in the theme folder, and as a plugin, I need to use my template (that is stored in the plugin's folders). (I assume that it is not 'polite' for my plugin to write a template file to the theme's folder.)
So, the question: create a Page programatically that uses a template file that is contained in the plugin's folder, not the theme's folder. Using a template allows the emoji graphics to be displayed by WP. Then I can copy/paste the generated page into Word, and the graphics will be there.