Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm creating my first plugin and it requires some pages with content to functionally work properly.

I was wondering if it is possible to show a message like "Click here to automatically add the required pages for this plugin" in the wordpress plugins area.

So when the user activates the plugin this message will show and if the user clicks the button a function will run that will add the pages necessary.

Any help in direction most appreciated.


share|improve this question

1 Answer 1

up vote 2 down vote accepted

You can add those without a button:

register_activation_hook( __FILE__, 'my_plugin_install_function');

function my_plugin_install_function()
   //post status and options
    $post = array(
          'comment_status' => 'closed',
          'ping_status' =>  'closed' ,
          'post_author' => 1,
          'post_date' => date('Y-m-d H:i:s'),
          'post_name' => 'Checklists',
          'post_status' => 'publish' ,
          'post_title' => 'Checklists',
          'post_type' => 'page',
    //insert page and save the id
    $newvalue = wp_insert_post( $post, false );
    //save the id in the database
    update_option( 'hclpage', $newvalue );

This function will run when the user installs the plugin. For super smart control you should check if that option already exists and if the id is not 0 (that means failure)

share|improve this answer
Hey ferenyl, Thanks for the response :) I'm aware of the activation_hook but i would prefer to have the option for the user to auto add content or not.. is this possible? –  Shoebox Dec 17 '11 at 0:29
Add a options page and create a form on that page. Send a get variable and check if isset($_GET['createpage']). if it is call a function. –  ferenyl Dec 17 '11 at 0:35

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.