Title: Creating new page using WordPress plugin
Last modified: May 18, 2021

---

# Creating new page using WordPress plugin

 *  Resolved [hermit1](https://wordpress.org/support/users/hermit1/)
 * (@hermit1)
 * [5 years ago](https://wordpress.org/support/topic/creating-new-page-using-wordpress-plugin/)
 * Hi folks,
 * I am building a plugin and very new to wordpress ecosystem. First of all I want
   to thank all community member to build something like wordpress. (coming from
   nodejs background).
 * What I want from my plugin is, when a user install this plugin, the plugin should
   automatically create a post / page , like the way we do from UI by clicking “
   Add new” submenu from “Page” menu. I want to do the same thing from my code.
 * Any reference or help is highly appreciated.
 * Thanks.
    -  This topic was modified 5 years ago by [hermit1](https://wordpress.org/support/users/hermit1/).
      Reason: grammetical mistake

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [5 years ago](https://wordpress.org/support/topic/creating-new-page-using-wordpress-plugin/#post-14418683)
 * Tis page is about creating database tables when you activate a plugin, but you
   can take out that part of things and add yoru own code to create pages.
 * [https://codex.wordpress.org/Creating_Tables_with_Plugins#Calling_the_functions](https://codex.wordpress.org/Creating_Tables_with_Plugins#Calling_the_functions)
 * To create pages (or posts or any other post type that you want to), you can use
   [wp_insert_post()](https://developer.wordpress.org/reference/functions/wp_insert_post/).
 * The only thing to be careful of is that you need to keep track of if the pages
   have been created or not, otherwise your plugin will create new pages every time
   someone activates it, so if they deactivate for any reason then reactivate it,
   it will still try to create the pages again unless you tell it not to.
 *  Thread Starter [hermit1](https://wordpress.org/support/users/hermit1/)
 * (@hermit1)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/creating-new-page-using-wordpress-plugin/#post-14423102)
 * Hi [@catacaustic](https://wordpress.org/support/users/catacaustic/)
 * Thank you for reply. I think I am confused or mistaken. I tried this solution
   and glad that it worked but it created “Post” not “Page”. What I mean that from
   the UI I can see there are two sections “Post” and “Page”. When I used wp_instert_post()
   api, it created a new post in “Post” section but what I wanted was to create 
   new page.
 *  [catacaustic](https://wordpress.org/support/users/catacaustic/)
 * (@catacaustic)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/creating-new-page-using-wordpress-plugin/#post-14423186)
 * It is the same function to insert a page so if you’re getting that you’re doing
   it right.
 * To make it a page, you need to look at the arguments that you give to that function.
   For this one case, you’d set ‘post_type’ as ‘page’ and That will create a page
   instead of a post, which is the default when nothing else is supplied.
 *  Thread Starter [hermit1](https://wordpress.org/support/users/hermit1/)
 * (@hermit1)
 * [4 years, 12 months ago](https://wordpress.org/support/topic/creating-new-page-using-wordpress-plugin/#post-14424467)
 * Perfect. It worked. thank you very much.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Creating new page using WordPress plugin’ is closed to new replies.

## Tags

 * [NewPage](https://wordpress.org/support/topic-tag/newpage/)

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 4 replies
 * 2 participants
 * Last reply from: [hermit1](https://wordpress.org/support/users/hermit1/)
 * Last activity: [4 years, 12 months ago](https://wordpress.org/support/topic/creating-new-page-using-wordpress-plugin/#post-14424467)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
