user1452376
user1452376

Reputation: 129

hook for new page in wordpress?

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

Answers (2)

vanurag
vanurag

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

SidFerreira
SidFerreira

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

Related Questions