Creating the pages by using script or in wordpress is very easy. You just need to the following code snippet for create pages programmatically in wordpress. Many times we need to create the default page or post in wordpress. You just need to the following code snippet in functions.php file or your can put following code in your plugin file.

create pages programmatically in wordpress

If you are the wordpress plugin or theme developer then following code sample is rally useful to create the empty post or page in wordpress.

global $user_ID;
$page['post_type']    = 'page';
$page['post_content'] = 'Put your page content here';
$page['post_parent']  = 0;
$page['post_author']  = $user_ID;
$page['post_status']  = 'publish';
$page['post_title']   = 'Your Page Title';
$page = apply_filters('yourplugin_add_new_page', $page, 'teams');
$pageid = wp_insert_post ($page);

Written by Purab

My name is Purab, Here is my Personal Blog: I contributor of many wordpress plugins and Drupal Modules. I am core developer of Drupal. Connect to on LinkedIn or Follow @purab on Twitter or Follow me on Google+ or Write Mail to or Chat with me on Skype : purabdk

Leave a Comment

Your email address will not be published. Required fields are marked *