Variables do not expand inside single quotes, so this– selected( $selected, '$post_type->name'
— is literally checking for a string that looks like ‘$post_type->name’. If you are saving the option names, it should work if you just remove the quotes (though I did not run your code to test that).
Your might be able to exclude what you want via the public
and _builtin
arguments to get_post_types
, but if you are looking to exclude a particular type other than what those arguments will do, I don’t see a way to do that directly, but there is a filter. It would likely be easier just to filter the post type out in your foreach
loop though.