Created
February 28, 2012 19:03
-
-
Save joelcloralt/1934408 to your computer and use it in GitHub Desktop.
Create Wordpress Page on Theme Activation
This file contains 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
// Create a page on theme activation | |
function privateMessagePage () { | |
$default_pages = array('This content is private'); //Page Title | |
$existing_pages = get_pages(); | |
$temp = array(); | |
foreach ($existing_pages as $page) { | |
$temp[] = $page->post_title; | |
} | |
$pages_to_create = array_diff($default_pages, $temp); | |
foreach ($pages_to_create as $new_page_title) { | |
$defaultPage = array( | |
'comment_status' =>'closed', | |
'ping_status' =>'closed', | |
'post_content' => 'This content is restricted to site members. Please contact us for more details.', | |
'post_excerpt' => 'This content is restricted to site members. Please contact us for more details.', | |
'post_name' => 'private-content', | |
'post_status' => 'publish', | |
'post_title' => 'This content is private', | |
'post_type' => 'page' | |
); | |
$result = wp_insert_post($defaultPage); | |
} | |
} | |
add_action('init', 'privateMessagePage'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment