Reputation: 129
I want to add a new page by my plugin.I tried a lot but failed. What is the hook for creating a new page?Please help.
function add_new_page(){
.....
}
action('init','add_new_page');
Upvotes: 1
Views: 3675
Reputation: 297
If you know all the tables then just write directly to the database for new page creation.
here is the help link http://codex.wordpress.org/Function_Reference/wp_insert_post
Upvotes: 1
Reputation: 578
If I understood properly, you want to create a new record in the database that is a page. If indeed this is the case, you need to programatically add a new POST of type PAGE (yeah, it is a bit confusing).
To this, you will setup an associative array with the details of your post and use the wp_save_post
function, that is here: http://codex.wordpress.org/Function_Reference/wp_insert_post.
Just remember to check if your page already exists before inserting again, or it will create thousands of pages.
Upvotes: 4