Skip to content

Instantly share code, notes, and snippets.

@WebEndevSnippets
Created January 10, 2013 20:05
Show Gist options
  • Save WebEndevSnippets/4505328 to your computer and use it in GitHub Desktop.
Save WebEndevSnippets/4505328 to your computer and use it in GitHub Desktop.
WordPress: Automatically Create Page on Theme Activation
$page = get_page_by_title( 'Submissions Test' );
if ( null == $page ) {
$args = array(
'post_type' => 'page',
'post_title' => 'Submissions Test',
'post_status' => 'private',
'post_content' => 'This page was automatically created for your theme. This page displays your Submissions entries and SHOULD NOT BE REMOVED.',
'comment_status' => 'closed',
'ping_status' => 'closed',
);
$id = wp_insert_post( $args );
if ( ! is_wp_error( $id ) )
update_post_meta( $id, '_wp_page_template', 'page_submissions.php' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment