5) Create Page

If we put this code into the file it will create a page:

create page

The first line, register_activation_hook asks to run the createPage function when the plugin is first activated.

In the createPage function, the important command is wp_insert_post. The parameter it takes is an array with information about the page.

$page is an array with five elements: post_content, post_parent, post_status, post_title, and post_type. These are the names of the elements of the $page array.

The most interesting one of the five elements is post_content. The text string [zapform] will be the only content we put into this newly created page. The text string [zapform] does nothing until we make it into a shortcode (see Add Shortcode below).

Advertisements