Assign a Page Template to a Form

WordPress supports Page Templates for Pages, Posts and Custom Post Types. You can assign different templates to different Pages or Posts. 

Wordpress handles Pages different than Posts. 


Page templates are natively supported and you can select the page template in the page edit screen. 
The page template get stored with wp_insert_post as attribute 'page_template' => 'template_name.php'

Posts and Custom Post Types

Are not natively active in WordPress but still supported. Plugins or Themes can enable the functionality for Posts or any Post Type.

The page template is set as hidden post meta '_wp_page_template' 


If you want to assign a page or post template to a form it will be different for Pages or Custom Post Types

Add this function to your function.php and change the Form Slug and template name to your needs

Posts and Custom Post Types

Just add a hidden field to the form with slug '_wp_page_template' and value of the page template 'template_name.php'

Still need help? Contact Us Contact Us