Okay, the solution is this below to hide Comments menu if the site doesn’t have any comments (approved, pending, trash or spam).
function remove_commentsmenu() {
global $user_ID;
if ( 1 > wp_count_comments( get_the_ID() )->total_comments && 1 > wp_count_comments( get_the_ID() )->trash ) {
remove_menu_page( 'edit-comments.php' );
}
}
add_action( 'admin_menu', 'remove_commentsmenu' );
Related Posts:
- Adding button to wordpress menu
- comment_post (if comment is approved OR $comment_approved === 1) not working?
- Creating plugin with front-end pages
- Add custom field on admin dashboard comments / reviews
- Adding markup to sub menu based on class
- Featured image in menu wordpres
- Show all people who commented on all posts by an author
- How to make only the valid active page of a multilevel menu active with – “.nav li.current-menu-item a”?
- Replace jQuery with PHP or CSS for Customized WordPress wp_nav_menu
- How to pass parameters in wordpress shortcode?
- Display the list of user’s comments + the post title + date
- Commenting requires wordpress login, wordpress discussion and post comments tick boxes are checked
- dynamic php menu with hidden sub-categories only showing when the category name is clicked
- How to set Nav as a default menu in wordpress
- How to put 2 php codes in functions.php without site crashing
- Menu not updating for logged in users after redirect
- Comments on my custom post type
- Fetch commens from a specific post
- wp_get_nav_menu_items() with ACF
- How to switch between two primary menus (programatically0
- How to let mobile navigation menu close when link is clicked?
- Redirect User when they click Menu Option
- Used a code to revoke some dashboard menus for my contributors but for some reason it’s revoked me access to the editor [closed]
- Get Child of Child Pages in custom Menu
- Closing Comments conditionally in comments.php
- How to give custom roles the capability to edit one Menu instead of every Menu
- Primary navigation menu with timed items from custom post type
- PHP warning with code for nav menu walker [duplicate]
- Add element after navigation element title don’t works like I expect
- How to disable sub menu items from being created?
- String replace for Login/Logout concatenation problem in menu
- Bring Font Awesome icons inside menu A tags
- Difference between “Walker_Nav_menu” and “walker”
- Add parent menu item in sub-menu in custom nav_walker
- How to add delete, approve, spam Links to Comments
- How to create a sub-page of sub-page?
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- Real time notification on user profile after new comment
- What’s the correct offset value for order ASC?
- Vertical Menu for one page only
- Display specific main Sub Nav on Woocommerce product pages
- PHP drop down menu for my get_category child of
- How can I output the slug of a comment author?
- Widget Logic – display on page and all child
- How limit the width of a fixed menu-bar on scroll?
- How can I enqueue comment-reply script only on certain page?
- Pulling a variable into the wp_nav_menu function
- Beyond widget side menu editing, with the php page, custom template
- How to list categories by page id in wordpress
- Editing existing pre-created menus in PHP
- Two theme locations for two menus, but only one is showing up
- wp_nav_menu doesn’t work in a duplicate server
- How I can add div to menu?
- wp_nav_menu prints children with parent name
- wp nav menu without label
- Contact form field in wordpress menu
- WP Admin Bar – Get current theme name as custom menu title
- Add extra markup to WP menus
- How to call a certain object/menubar in a PHP file
- Getting most popular posts based on Facebook comments count
- Active class not working on custom menu link using add_menu_page
- A Space being added to url generated by custom plugin
- Sidebar current menu item for parent
- Using ‘array’ method in wp_nav_menu causes it to disappear
- Remove all nav menu classes except those which begin with certain letters
- How to add a code for lastpostdate after/inside a specific menu link?
- Add the “.current-menu-item” class to tag?
- WordPress – show number of comments for each post in widget
- How does add_action ‘comment_post’ work?
- How to get the count for each taxonomy term
- WP_Nav Highlight Parent Issue
- WordPress adding in site URL to header links
- How to change the menu color
- Can’t remove menu items added by plugin
- Custom Links in Walker Class
- Submenu opened problem
- Custom action on comment post
- if is_home(), change class of menu-item-225 of wp_nav_menu
- WordPress most commented posts of last X days
- Nav Menu Display
- Adding a unique class to wp_nav_menu
- Change order that the menu is generated with wp_list_pages
- I am extending Walker_Nav_Menu: How can I get the number of children elements of the current item?
- Catchable fatal error in appcloud free theme by Tokokoo
- How do I modify the with wp_nav_menu()
- How do I call comments_template(); from a plugin file?
- Make a permalink to the most recent blog post
- How to get the rating value of each comment
- Trouble figuring out how to get my button to submit comment
- WordPress menu links with images & class selection
- How to convert my comment.html to comment.php
- Open WordPress Page from selected option dropdown
- Inserting a shortcode into a genesis menu?
- Remove Unused Menu Locations
- Redirect users by role to custom pages
- Custom Navigation Bar JSON Syntax Error in JSON at Position 0
- How to add different menu items on different menus?
- Custom nav with bootstrap dropdown
- Guests comment form – prevent duplicate email addresses
- Permissions error when I use my plugin to delete comments in the front-end