Created
February 27, 2020 15:08
-
-
Save digisavvy/21c8b0626f7a0f826833b162bf7340c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function wpse196289_default_page_template() { | |
| global $post; | |
| if ( 'page' == $post->post_type | |
| && 0 != count( get_page_templates( $post ) ) | |
| && get_option( 'page_for_posts' ) != $post->ID // Not the page for listing posts | |
| && '' == $post->page_template // Only when page_template is not set | |
| ) { | |
| $post->page_template = "page-mytemplate.php"; | |
| } | |
| } | |
| add_action('add_meta_boxes', 'wpse196289_default_page_template', 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment