jjgrainger / wp-custom-post-type-class

A PHP Class for creating Wordpress Custom Post Types easily
MIT License
416 stars 114 forks source link

is it possible to pass show_in_nav_menus? #72

Open sunsgs opened 6 years ago

sunsgs commented 6 years ago

I need to add automatically to primary_menu (in the front end) all CPTs. Is it possible to pass show_in_nav_menus attribute?

jjgrainger commented 6 years ago

Hi @sunsgs

Yes, you can pass options for a post type when creating it like so...

$books = new CPT('book', [
    'show_in_nav_menus' => true,
]);

The second argument is the options for the CPT that matches the WordPress arguments for register_post_type

sunsgs commented 6 years ago

thanks. In this way i can select add all my custom post type automatically without to select on by one in menu section?

jjgrainger commented 6 years ago

@sunsgs yes, I believe so.