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 want to develop a plugin that generates a page and embeds the page link in pages menu in the client part at the time of plugin activation.

Please help me with this.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

You can create the page using wp_insert_post() and make sure you send post type as 'page'. and if the user nav menu uses wp_list_pages the page will be added to the nav menu automatically and to run it on activation you can have you plugin check if it exists and save its id so it will only create it once.

$my_page = get_option('my_plugin_page');
if (!$my_page){
    // Create post/page object
    $my_new_page = array(
        'post_title' => 'My page',
        'post_content' => 'This is my page content.',
        'post_status' => 'publish'
    );

    // Insert the post into the database
    $my_page = wp_insert_post( $my_new_page );
    update_option('my_plugin_page',$my_page);
}
share|improve this answer
    
hey sorie for the late response .. Anyways, thanks for the answer . . :)) –  coosal Mar 16 '11 at 6:54
add comment

Your Answer

 
discard

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.