I'm trying to add a custom post type to a custom page called slides (admin.php?page=slides) and it doesn't want to work. This is my first attempt at a technical plugin using pages. The custom page gets created fine however when I include the function to generate the custom post type it doesn't load into the view. My page generation code is:

    'Slides', 'Slides', 'manage_options', 
    'sliderama-slides', 'slides_page'); 

And my function to register the post type is:

function slides_page()
$labels = array(
    'name' => _x('My Slides', 'post type general name'),
    'singular_name' => _x('Slide Item', 'post type singular name'),
    'add_new' => _x('Add New', 'Slide item'),
    'add_new_item' => __('Add New Slide Item'),
    'edit_item' => __('Edit Slide Item'),
    'new_item' => __('New Slide Item'),
    'view_item' => __('View Slide Item'),
    'search_items' => __('Search Slide'),
    'not_found' =>  __('Nothing found'),
    'not_found_in_trash' => __('Nothing found in Trash'),
    'parent_item_colon' => ''

$args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'query_var' => true,
    'menu_icon' => null,
    'rewrite' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array('title','editor','thumbnail')

register_post_type( 'slideroo' , $args );


  • 1
    Please someone correct me if I am wrong. You can't add a custom post type to a page. I think you may not be explaining yourself quite right.
    – deflime
    Jul 15, 2014 at 21:07
  • Second the first comment. Not clear on exactly what you are trying to do. I think it is safe to assume ( based on admin.php?page=slides) that you are having trouble creating the WP Admin menu item.
    – jdm2112
    Jul 15, 2014 at 21:24

2 Answers 2


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

(callback) (optional) The function to be called to output the content for this 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.

  • Thanks, Had overthought the process. Have created a custom post type and created submenu pages to said post type. Jul 17, 2014 at 8:18

I think what you are looking for is: Create a template for your custom page 'slides.' Inside of that template, use WP_Query to call in your custom post type. Like so:

<?php $loop = new WP_Query( array( 'post_type' => 'slideroo', 'posts_per_page' => -1 ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); $do_not_duplicate = $post->ID; ?>
  // Posts format here
<?php endwhile; ?>

Not sure if that's what you really need.

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.