I'm learning plugin development and need to create a plugin to display data from a database. I want this plugin to have several separate pages (not insert content into the home page, etc.). Alost like a whole sub-site but all custom code (similar to what bbpress does).

Can anyone suggest sample as to how my plugin can have it's own page(s) at it's own url ?

Newbie thanks !

1 Answer 1


One way this is done is to first create shortcodes that generate the content you want to display on your pages.

Then, upon plugin activation, programmatically add your pages (or custom post type if that is more appropriate) and set their content to your shortcodes using wp_insert_post

Now you have a set of pages ready out of the box that your users can use. However, they can still alter the pages or move the content to their own custom pages if they prefer.

Finally, if your plugin requires Knowledge of which page contains which content, make sure you have a setting in your settings panel to assign any custom page the user likes (for example, like how WordPress allows you to set any page to be the home page)

Hope that helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.