I've added this code to my magazine.php file into the plugin, but when it is activated, the CPT does not appear in the dashboard menu. Do you figure out why? it is a really minimalistic CPT, i do not understand why it does not work...

add_action('init', 'mc_setup_post_type');

function mc_activation(){
// trigger the wp function that registers the custom post type

//clear the permalinks after the post type has been registered

function mc_setup_post_type(){
//register the "magazine" custom post type

register_post_type('magazine', array(
                              'labels' => array(
                                        'name' => 'magazine'),
                              'public' => 'true'));
  • Is magazine.php included somewhere or it's an orphan file? Please make clear what your plugin is.
    – Max Yudin
    Jun 8, 2019 at 6:10
  • @MaxYudin, the magazine.php is included into the plugin folder structure, and it is showed into the plugin wordpress directory and can be activated. Also, the register_activation_hook(), which is into the same php file, works and it creates the table needed to store the magazines records Jun 8, 2019 at 7:15

1 Answer 1


The problem is that you've set the value for 'public' incorrectly. That argument is a boolean, meaning it's true or false, and in PHP these need to be written without quotes to be correct:

        'labels' => array(
                'name' => 'magazine',
        'public' => true,

For the post type to appear in the admin sidebar, 'show_in_menu' needs to be true. The default value of 'show_in_menu' — if it's not provided — is the same as 'show_ui', which itself defaults to the value of 'public'. this is why 'public' being set incorrectly was causing the problem.

The reason Pravin's answer works is because he's manually setting 'show_in_menu' to true. But while this makes the post type appear in the admin menu, it's still not set to public correctly, which means that the post type still won't be publicly visible. The 'show_in_menu' argument is not required if 'public' is set correctly.

  • 1
    thanks @jacob-peattie, that's it, i've copied the code from a place where it was quoted and i didn't realized it. Jun 8, 2019 at 7:18

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.