Title: wp_admin_bar_comments_menu
Published: April 25, 2014
Last modified: August 20, 2026

---

# wp_admin_bar_comments_menu( WP_Admin_Bar $wp_admin_bar )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_admin_bar_comments_menu/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/functions/wp_admin_bar_comments_menu/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_admin_bar_comments_menu/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_admin_bar_comments_menu/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_admin_bar_comments_menu/?output_format=md#wp--skip-link--target)

Adds edit comments link with awaiting moderation count bubble.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_admin_bar_comments_menu/?output_format=md#parameters)󠁿

 `$wp_admin_bar`[WP_Admin_Bar](https://developer.wordpress.org/reference/classes/wp_admin_bar/)
required

The [WP_Admin_Bar](https://developer.wordpress.org/reference/classes/wp_admin_bar/)
instance.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_admin_bar_comments_menu/?output_format=md#source)󠁿

    ```php
    function wp_admin_bar_comments_menu( $wp_admin_bar ) {
    	if ( ! current_user_can( 'edit_posts' ) ) {
    		return;
    	}

    	$awaiting_mod  = wp_count_comments();
    	$awaiting_mod  = $awaiting_mod->moderated;
    	$awaiting_text = sprintf(
    		/* translators: Hidden accessibility text. %s: Number of comments. */
    		_n( '%s Comment in moderation', '%s Comments in moderation', $awaiting_mod ),
    		number_format_i18n( $awaiting_mod )
    	);

    	$icon   = '<span class="ab-icon" aria-hidden="true"></span>';
    	$title  = '<span class="ab-label awaiting-mod pending-count count-' . $awaiting_mod . '" aria-hidden="true">' . number_format_i18n( $awaiting_mod ) . '</span>';
    	$title .= '<span class="screen-reader-text comments-in-moderation-text">' . $awaiting_text . '</span>';

    	$wp_admin_bar->add_node(
    		array(
    			'id'    => 'comments',
    			'title' => $icon . $title,
    			'href'  => admin_url( 'edit-comments.php' ),
    		)
    	);
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/admin-bar.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/admin-bar.php#L1122)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/admin-bar.php#L1122-L1146)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_admin_bar_comments_menu/?output_format=md#related)󠁿

| Uses | Description | 
| [_n()](https://developer.wordpress.org/reference/functions/_n/)`wp-includes/l10n.php` |

Translates and retrieves the singular or plural form based on the supplied number.

  | 
| [WP_Admin_Bar::add_node()](https://developer.wordpress.org/reference/classes/wp_admin_bar/add_node/)`wp-includes/class-wp-admin-bar.php` |

Adds a node to the menu.

  | 
| [wp_count_comments()](https://developer.wordpress.org/reference/functions/wp_count_comments/)`wp-includes/comment.php` |

Retrieves the total comment counts for the whole site or a single post.

  | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  | 
| [number_format_i18n()](https://developer.wordpress.org/reference/functions/number_format_i18n/)`wp-includes/functions.php` |

Converts float number to format based on the locale.

  | 
| [admin_url()](https://developer.wordpress.org/reference/functions/admin_url/)`wp-includes/link-template.php` |

Retrieves the URL to the admin area for the current site.

  |

[Show 3 more](https://developer.wordpress.org/reference/functions/wp_admin_bar_comments_menu/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_admin_bar_comments_menu/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_admin_bar_comments_menu/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.1.0](https://developer.wordpress.org/reference/since/3.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_admin_bar_comments_menu%2F)
before being able to contribute a note or feedback.