i am creating wordpress plugin for my own contact us page. in that i am creating one contact us page when plugin activated.
my code is
function createPage()
{
global $user_ID;
$page['post_type'] = 'page';
$page['post_content'] = 'hello this page created by plugin';
$page['post_parent'] = 0;
$page['post_author'] = $user_ID;
$page['post_status'] = 'publish';
$page['post_title'] = 'Dynamic page';
// $page = apply_filters('yourplugin_add_new_page', $page, 'teams');
$pageid = wp_insert_post ($page);
}
and it’s working fine. it’s creating new page also. now my question is i want to assign specific template to this page. i don’t know how to do it..
can you please suggest me how to do it?
Thanks in advance
The filename of a Page’s assigned custom template is stored as the value of a Custom Field named ‘_wp_page_template’ (in the wp_postmeta database table).So you can set that page meta to that particular template name.