Software Developer

Assign a Page Template to a Page in functions.php

This lets you force a certain page to use a specified page template file.

This is useful if you want it to use some custom page template for a certain page, and for whatever your reason, you must assign it via a function file.

Replace $page_template with your custom template file, relative to your theme’s template directory.
Example:
contact-page-template.php
or
page-templates/full-width.php

Replace $page_id with your page id (integer).


//use unique template
update_post_meta(get_option( $page_id ), '_wp_page_template', $page_template);

By

Questions and Comments are Welcome

Your email address will not be published. All comments will be moderated.

Please wrap code in "code" bracket tags like this:

[code]

YOUR CODE HERE 

[/code]