There are times when you need to type in all of the pages, requested by the client, which is really frustrating while using WP Dashboard. This little snippet should be useful – place it in the functions.php file.


// if already inserted omit
if ( get_option( ‘set_nav’ ) != “yes” ) {

$pages = array( ‘Home’, ‘About’, ‘Portfolios’,
‘Resources’, ‘Services’, ‘Need Talent?’,
‘Need Work?’, ‘What’s New?’, ‘Contact Us’,
‘Terms of Use’, ‘Privacy Policy’ );

// Create post object
foreach ( $pages as $page ) {

$my_page = array(
‘post_title’ => $page,
‘post_content’ => ”,
‘post_status’ => ‘publish’,
‘post_type’ => ‘page’

// Insert the pages into the database
wp_insert_post( $my_page );
update_option( ‘set_nav’, ‘yes’ );


So $pages variable is an array of all the page titles that would get to be created, after doing so, an option ‘set_nav’ is added to the db so that these pages wouldn’t be created all over again.

If in need of doing that again, you can remove all of the pages and then add a

delete_option( ‘set_nav’);

Before the whole code. This is probably not the best approach, including wp-blog-header.php and executing that code outside of the current theme wouldn’t add any extra entries to the options table + I’m not even storing that in an associative array which might also affect the site performance – take it into account 🙂