You can create the page using wp_insert_post()
and make sure you send post type as ‘page’. and if the user nav menu uses wp_list_pages
the page will be added to the nav menu automatically and to run it on activation you can have you plugin check if it exists and save its id so it will only create it once.
$my_page = get_option('my_plugin_page');
if (!$my_page){
// Create post/page object
$my_new_page = array(
'post_title' => 'My page',
'post_content' => 'This is my page content.',
'post_status' => 'publish'
);
// Insert the post into the database
$my_page = wp_insert_post( $my_new_page );
update_option('my_plugin_page',$my_page);
}
Related Posts:
- What are the advantages to the Settings API?
- Changing Plugin Load Order
- How should you hook a session_start() when authoring a plugin?
- How to create a plugin that only operates on the home page?
- Adding callback function for wp_ajax_ has no effect
- Why are two functions over-riding each other?
- Create a plugin to change the action to which a function is hooked
- how to set context in WordPress for unit testing
- Why is the reset password key missing in the reset password email?
- Paging on a future post loop?
- How to pass custom options from widget form to widget update callback?
- WordPress admin deleted user details not removed in database. How to delete WordPress Users from Database
- plugin development: storing language specific options
- Support auto-save and revisions for custom fields
- Gutenberg – What is the best way to save/update post meta?
- Dequeue theme stylesheets but keep widget styling on custom page template
- Why do I need to check if wp_nonce_field() exists before using it
- Save Checkbox value in Plugin [duplicate]
- Plugin updates, version dependencies, and backwards compatibility
- Where and how does WordPress store and use its plugin and hook information?
- Cache directory needed for plugin
- edit_{$taxonomy} | Hook
- Worpdress cannot create directory
- Using the default wordpress uploader inside plugin
- WordPress after content Hook & external template part
- How to associate an existing user to a site in a multisite setup programmatically
- Changing upload dir in a plugin regardless of post type
- Alter post object before display
- Howto: Use Custom Post Types as Submenu Items in Admin
- get_query_var not works
- How to localize admin.php only once
- Failed to Open Stream: Permission Denied While Writing to an XML File in a WordPress Plugin
- How can I get a list of CPT inside a plugin file?
- Creating a custom Gutenberg block with columns
- Show/Hide ‘add new user’ custom fields in wordpress admin panel by click another field
- Capture mediaelement events
- Dynamically creating classes for Widget API
- Add a new confirmation page before saving
- Plugin is not generating title tags on any pages or posts
- Plugin Development/ Stop CSS clashes.
- Add Link Category on Activation?
- How to query children by post name/slug
- get_the_tags with separator control?
- Creating multiple wp_editer() text fields in for loop — the text/visual switch only works for first editor
- Displaying “One Time” Notification in Plugins
- Is it the right way to add jquery and css in wordpress?
- Print Dashboard submenu name and filename
- Are there any security risks when submitting data-attribute data through AJAX?
- My stylesheets are not enqueuing
- Customize existing menu item
- Dynamically generate meta tags and titles for a wordpress page
- PHP File_exist() not working – Checking if File Exist in WordPress Theme Directory
- Woocommerce inventory [closed]
- Invalid hook call on save, not edit when using swiper slider
- Call to undefined function is_home() or any conditional tags
- how to load the comment template from a plugin
- Change/Set Page Title and Meta Tags from Page Called within a Plugin
- WooCommerce Endpoints content
- Look for a file in a theme before loading from plugin
- Include HTML (Bootstrap Modal Box) with a plugin into my header
- when i activate my plugin i want to auto create pages with shortcodes
- Using init hook for register_taxonomy is causing invalid_taxonomy in wp_insert_term()
- Simple plugin don’t display content
- How can I prevent ‘500 internal server error’ because of a long install process?
- How to display TinyMCE HTML view?
- Downloading File via headers doesnt work
- get the permalink error
- Cannot output plugin twice with shortcode
- Gutenberg – Call google map render function in save after DOM has been rendered
- Does $this context change in an AJAX callback?
- Home page is not loading, where in other pages are displaying on the site
- Custom table / Alternative to WP_List_Table
- WordPress custom url without using any of the custom tags given
- WordPress with React: Saving and Using Data Collected with fetch
- How to call a plugin function from a page
- Code for cron to delete posts that contain specific expression (e.g. “unable to fetch” every 30 minutes
- If user is logged-in display/hide widgets ( siteorigine) [closed]
- Javascript not being loaded only in custom taxonomy template
- User Registration Moderate
- pull data from wordpress database
- Implementing Select2 plugin into WordPress
- Object Oriented plugin, add action and variables
- Why user is added back in database after deletion?
- add_action priority and taxonomy used in plugin
- Tracing dashboard publish settings from input form in WordPress
- Post data in wp-admin to external database
- Virtual Page with Registration form
- Images not displaying on live server
- redirect word-press page with page values
- How to do searching based on keywords added in page
- How to only Load scripts on variable products page
- Using tag or inline style attribute?
- Forcing the Uninstall Hook to fail
- remove () from category number [closed]
- Anyway to prevent admin from seeing other admin’s product?
- Build a dynamic block using the default attributes
- Bulk post approval and publishing doesn’t work
- Show Admin Menu
- How to replace content of a block in and re-render on change?
- extending a core block doesn’t work inside the editor