Created
September 18, 2018 07:33
-
-
Save dasbairagya/5db1d55f8ff9a4e42c97dfc529878754 to your computer and use it in GitHub Desktop.
Automatically create page and assign a page template to it....
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
| <?php | |
| $awesome_page_id = get_option("awesome_page_id"); | |
| if (!$awesome_page_id) { | |
| //create a new page and automatically assign the page template | |
| $post1 = array( | |
| 'post_title' => 'Awesome Page!', | |
| 'post_content' => "", | |
| 'post_status' => "publish", | |
| 'post_type' => 'page', | |
| ); | |
| $postID = wp_insert_post($post1, $error); | |
| update_post_meta($postID, "_wp_page_template", "school.php"); | |
| update_option("awesome_page_id", $postID); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment