You have misunderstand the purpose of add_submenu_page and it’s callback function.
If you take a look at WordPress Codex you will see that the purpose of this function , in your case the slides_page function, is to output the content of the page. ie output HTML code etc
$function
(callback) (optional) The function to be called to output the content for this page.
Default:
http://codex.wordpress.org/Function_Reference/add_submenu_page
You have to separate the presentation from the logic of your plugin.
You can register your custom posts when the user activates the plugin using the register_activation_hook hook.
Related Posts:
- Is It Possible To Add Custom Post Type Menu As Another Custom Post Type Sub Menu
- Redesigning Custom Post Type “Add New” page
- How Do I Use The WordPress Plugin Posts 2 Posts by Scribu?
- Removing an admin page added by a 3rd party plugin. Gravity forms in this example
- Jetpack plugin (ShareDaddy): Prevent share buttons showing on custom post types?
- Getting Custom Post Type content from main-site of a Multisite
- Custom database or Custom Post Types?
- Custom comment type maybe?
- Prevent page slug from interfering with custom post type archive permalink?
- Twillio How To Send SMS for Custom Post Type
- Master menu item for multiple plugins?
- Seriously stuck with some custom meta box/plugin stuff
- Themes VS Plugins [duplicate]
- How to make a WP admin button/menu similar to Jetpack Notifications?
- Enable comments for post with comments meta box removed
- wp_verify_nonce() why return false?
- Detecting when a custom taxonomy has been changed and display alert?
- How to Build a Movie Library in WordPress 3.x
- I need to add a custom “cover” to every new post — plugin or custom setup?
- Plugin “Meta Box”: Implementing meta boxes in custom post type
- Change the $parent_file of a plugin page
- Plugin allowing for artists, events and venues
- Disable Other Plugins on my Custom Post Type?
- How to get images from EDD post?
- custom taxonomy and custom post type url conflict
- RW Meta Box ,Problem setting post title
- dynamically generating plugin syntax
- Exclude post by custom meta with pre_get_posts
- get_post_type() and WP_QUERY issue
- get_post_type on post.php
- Custom post type – no layout section of Document tab, and no author choice
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- Keep a post copy when this one is updated – issue
- how to add a button next to the wordpress view button?
- Dynamic admin submenu
- WP Plugins – Use includes to display page content
- Adding CSS to custom post type admin page causes error
- ACF: post query, hide duplicate values [closed]
- Redirect to another page using contact form 7? [closed]
- Custom setup of wordpress comments that are displayed
- Move plugin-settings to ‘Settings’-menu in the admin
- creating a plug in that would tap into save/update action of posts [closed]
- Amazon.com intergration with WordPress?
- Sticky option for custom post types without using custom fields or plugins
- Why WP_Screeen doesn’t show all options with admin_body_class
- Adding custom meta boxes to specified custom post type
- How do I make reusable content blocks for header and footer when using WordPress headless with another front-end?
- Plugin Admin Menu Boiler Plate
- Plugin – Admin menu page broken url
- Preview with Custom Post Type Not Working
- 2 wordpress site same database
- How to Include Custom Post Content From Plugin
- Custom post type change excerpt more and excerpt length
- What hook can I use to modify custom post data before it is displayed on the page?
- Order posts of a custom post type by the event date using FT Calendar Plugin
- Custom Post Type template for homepage
- Custom page in plugin visible in menu
- How display specific category post to specific users?
- Best method of implementing compartmentalized custom post types on a multi-site network
- Need to edit author permissions | custom taxonomy
- Is it possible to pin a post in second position from top
- How to search post titles with whole words only, but not the exact word only?
- Save log for imports in WordPress database – options-table, custom post type or other place?
- Remove custom taxonomy name from the slug – Custom Post Type UI
- How to display emails as a post?
- Error in Fetching Custom Post Type parent Category URL (slug)
- Register PODS Custom Field with WPGraphQL [closed]
- Hidden permalink different from displayed permalink
- Adding custom post category to categories widget
- Custom Post Type with Sequence ID
- How to arrange custom posts in the backend/admin by custom taxonomy
- Adding LOAD MORE on a page
- custom post type get_posts() function not work
- Create multiple posts when a custom post is created
- Cannot view Custom Post Type no matter what I try
- Show custom taxonomy not in submenu
- CPT-onomies CPT_TAXONOMY->get_terms extremely slow with 6K posts
- How can I pass value to function in add_menu_page?
- get recent 12 days post then random in wordpress
- Plugin menu replaced by another plugin?
- What method should I use for a sidebar widget that reads latest posts?
- Making a Custom Post Type Publish Loop
- WordPress User Frontend Editing Custom Fields
- How to list the categories by custom taxonomy created?
- Is a custom post type considred a plugin?
- Make a magic tag work with Custom Post Types
- Plugin link does not appear in my toolbar
- How to laod wp_enqueue_style to another header i created my self
- Looking for a plugins for organization portal (Staff, Units, Departments)? [closed]
- Wrong block appender button showing
- Select posts from list and add them in a new list
- jet engine listing for every single taxonomy in post type [closed]
- Failed to update a post when I add a taxonomy to it
- admin_enqueue_scripts using hook_suffix vs GET page
- Set the title of a custom post automatically by using info from custom fields?
- Submitting form to admin-post.php WordPress
- How to add CPT in Elementor pro search template
- how to compare date meta value in jet smart filter Date query?
- PHP Fatal error: Cannot redeclare distance() when making a new block
- How to Display News in a Timeline with Headline, Category, and Time?