Skip to content

Instantly share code, notes, and snippets.

@clarklab
Created November 5, 2012 18:06
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save clarklab/4019349 to your computer and use it in GitHub Desktop.
Save clarklab/4019349 to your computer and use it in GitHub Desktop.
set a page template programmatically in WordPress
update_post_meta( $post_id, '_wp_page_template', 'page-contact.php' );
@clarklab
Copy link
Author

So this one is pretty dang simple, I'm just sharing it because I used to not know that a page template could be set so easily.

@PrafullaKumarSahu
Copy link

can you please tell me how to do this using hook ?

@bahmanworld
Copy link

Nice 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment