When working with Oxygen, we need to go to Oxygen > Templates page in the admin several times especially during the initial stages of the development.

Wouldn’t it be handy to have a link in the WordPress admin bar that takes us to the Templates page so we can just go there with a single click regardless of where we are on the WP admin or frontend?

The code snippet below does just that.

add_action( 'admin_bar_menu', 'custom_add_templates_adminbar_item', 1001 );
/**
 * Adds "Templates" menu item in the WordPress admin bar.
 *
 * @param WP_Admin_Bar $admin_bar WP_Admin_Bar instance, passed by reference.
 */
function custom_add_templates_adminbar_item( $admin_bar ) {

    $admin_bar->add_menu(
        array(
            'id'    => 'templates',
            'title' => 'Templates',
            'href'  => admin_url( 'edit.php?post_type=ct_template' ),
            'meta'  => array(
                'title' => __( 'Oxygen Templates' ),
            ),
        )
    );

}

Code like this can be added using the Code Snippets plugin or a custom functionality plugin.

Need help implementing a tutorial in your site or want to hire me for custom work?

HIRE ME

Find the article helpful and wish to donate?

DONATE

Comments

You need to be logged in to view and post comments.
Not a member yet? Join here.
magnifiercross
>
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
%d bloggers like this: