Create post/page while installing your plugin

Plugin Name: NHD Test Plugin
Plugin URI:
Description: an test plugin
Author: Mahmudur Rahman Nahid
Version: 0.1-alpha
Author URI:


function nhd_test_install(){
    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';

    $pageid = wp_insert_post ($page);

There, I used


It fires when you active your plugin.

another function I used is,


which creates a page.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s