I constantly edit settings in the custom post types, so I wanted to create a way to get to the edit page for each post type without having to look through the side menu of each one.
I do recommend adding this to a custom plugin. let me know if you want me to add this as a component to the plugin I created. But if you prefer to just add it to your Child theme. Here is the code:
// ///// You can add this to your child theme.
function binaryblackboard_admin_bar_voxel_quicklinks( $admin_bar ) {
$args = array(
'public' => true,
'_builtin' => false
);
$output = 'names';
$operator = 'and';
$post_types = get_post_types( $args, $output, $operator );
if ( $post_types ) {
$admin_bar->add_menu( array(
'id' => 'binaryblackboard-sharing-is-caring-quicklinks',
'title' => __( 'Voxel Quick Links', 'binaryblackboard-sharing-is-caring' ),
'parent' => false,
'href' => '',
'group' => false,
'meta' => array(
'title' => __( 'Voxel Quick Links', 'binaryblackboard-sharing-is-caring' ),
// 'target' => '_blank',
'class' => 'binaryblackboard-sharing-is-caring-class',
'html' => false,
'rel' => false,
'onclick' => false,
'tabindex' => false,
),
));
foreach ( $post_types as $post_type ) {
$admin_bar->add_menu( array(
'id' => 'binaryblackboard-sharing-is-caring-vox-' . $post_type,
'title' => __( 'Edit post type - ' . $post_type, 'binaryblackboard-sharing-is-caring' ),
'parent' => 'binaryblackboard-sharing-is-caring-quicklinks',
'href' => '/wp-admin/edit.php?post_type=' . $post_type . '&page=edit-post-type-'. $post_type,
'group' => false,
'meta' => array(
'title' => __( 'Edit Post Type ' . $post_type, 'binaryblackboard-sharing-is-caring' ),
// ///// If you want the link to open in a new tab, uncomment the line below.
// 'target' => '_blank',
'class' => 'binaryblackboard-sharing-is-caring-sub-class',
'html' => false,
'rel' => false,
'onclick' => false,
'tabindex' => false,
),
));
}
}
};
add_action( 'admin_bar_menu', 'binaryblackboard_admin_bar_voxel_quicklinks', 100, 1 );