M
M
Morens2020-06-09 12:01:03
WordPress
Morens, 2020-06-09 12:01:03

How to add text to the toolbar?

I want to add just text to the toolbar, or more precisely, the number of the current version of WordPress.
But in the documentation and in all googled examples, a menu is added via add_menu.
So far, it has only turned out this way, but this is some kind of crutch.

add_action( 'admin_bar_menu', 'my_admin_bar_menu', 150 );
function my_admin_bar_menu( $wp_admin_bar ) {
  $wp_admin_bar->add_menu( array(
    'title' => 'Версия '.get_bloginfo ('version'),
  ) );
}


Tried it like that

add_action( 'wp_before_admin_bar_render', 'custom_toolbar', 99 )
function custom_toolbar() {
  bloginfo ('version');

}


But this does not display in the toolbar at all.

How can I display only text?
Additionally: I want to display it on the right, before the username. No matter what numbers I put in the hook, it is still displayed on the left side. How to display it on the right side?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question