Is it possible to have any control over the screen options for Appearance>Menus
. I am working on a theme and with a fresh WordPress install where I had never touched any of the screen options ( at least not under Appearance>Menus anyway ). I had 3 custom post types. Of these one was “missing”. I investigated Screen Options and it turned out that one was unchecked, while the other two were checked. I don’t know what I did to get it this way but I would like it to be consistent for users anyway. Has anyone got any ideas or information on this front? Ideally I would like to know that all three custom post types would be checked on a fresh install or a new user.
Leave a Reply
You must be logged in to post a comment.
This option is stored in the
wp_usermeta
table with themeta_key
name ofmetaboxhidden_nav-menus
.If we hide all the boxes, this is the
meta_value
of the option:There is one CPT,
portfolio
. If we wanted for it to be always visible every time the user visits the page (/wp-admin/nav-menus.php
), this code would do that:But this forces the CPT to be visible even if the user un-checks the Screen Option. In the next visit to the page, the box will be visible again.
To do it one time after user registration, the action hook
user_register
should be used together with the functionupdate_user_meta
.To do it on a fresh install, a custom
install.php
could be used. Maybe another technique is available, but not sure about it…