Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (isset($_GET['activated']) && is_admin()){
- add_action('init', 'create_initial_pages');
- }
- function create_initial_pages() {
- $pages = array(
- // Page Title and URL (a blank space will end up becomeing a dash "-")
- 'Services' => array(
- // Page Content // Template to use (if left blank the default template will be used)
- 'Services Content'=>'page-bottom-sidebar.php'),
- 'Prices' => array(
- 'Prices Content'=>'page-wide.php'),
- 'F A Q' => array(
- 'FAQ Content'=>' '),
- );
- foreach($pages as $page_url_title => $page_meta) {
- $id = get_page_by_title($page_url_title);
- foreach ($page_meta as $page_content=>$page_template){
- $page = array(
- 'post_type' => 'page',
- 'post_title' => $page_url_title,
- 'post_name' => $page_url_title,
- 'post_status' => 'publish',
- 'post_content' => $page_content,
- 'post_author' => 1,
- 'post_parent' => ''
- );
- if(!isset($id->ID)){
- $new_page_id = wp_insert_post($page);
- if(!empty($page_template)){
- update_post_meta($new_page_id, '_wp_page_template', $page_template);
- }
- }
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment