can any one test this at his installation? code test for auto creation of pages
-
in the functions.php file of the default theme for the sub-blogs.
add_action('wpmu_activate_blog','my_default_pages'); function my_default_pages(){ $default_pages = array('Home','About','Contact'); $existing_pages = get_pages(); 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){ // Create post object $my_post = array(); $my_post['post_title'] = $new_page_title; $my_post['post_content'] = 'This is my '.$new_page_title.' page.'; $my_post['post_status'] = 'publish'; $my_post['post_type'] = 'page'; // Insert the post into the database $result = wp_insert_post( $my_post ); } }
what do you say? any suggestions about why it doesn’t work?
it supposed to be very simple…thanks,
asaf.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘can any one test this at his installation? code test for auto creation of pages’ is closed to new replies.