Show comments menu in dashboard only if the site has comment

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’ );

Prev / Next menu item

I wrote this short-code plugin. To use it add the following shortcode to any page or inside a shortcode widget. [menu_navigator menu=’The name of your menu’] menu will default to “Table of contents” if not specified. To install, just save to a file named shortcode-blazoruniversity-menu-navigator.php, zip it up, and then upload it as a plugin. … Read more

How to make a customize role and view a specific plugins base on that role?

You can a custom admin page with add_menu_page function. The function has a argument $capability which you can set the which users will be able to view and access the page add_menu_page https://developer.wordpress.org/reference/functions/add_menu_page/ Roles and capabilities https://wordpress.org/support/article/roles-and-capabilities/

Hide Menu Unless Logged In

Assuming you have the ability to either edit the theme or child theme, in the file where the menu is called (probably header.php), use something like this: <?php if( is_user_logged_in() ) : wp_nav_menu( array( ‘theme_location’ => ‘header-nav’, ‘menu_id’ => ‘header-menu’, ) ); endif; ?> That’ll be the preferred option because it won’t load the navigation … Read more

Replace menu links with # and add name to its li

I want the URLs of the nav-items to be replaced with # You can use the nav_menu_link_attributes hook to set the custom href value like so: add_filter( ‘nav_menu_link_attributes’, function ( $atts, $item, $args ) { if ( ‘menu-categorias’ === $args->theme_location && ‘category’ === $item->object ) { $atts[‘href’] = ‘#’ . get_term_field( ‘slug’, $item->object_id ); } … Read more

Can’t extend some core classes

You can extend it, but the class definition and any code that uses it, can’t run outside of the admin area. Wrap your class in this conditional: if ( is_admin() ) { … } If you are trying to use this on the frontend or other non-Admin areas, do not do that. Generally, classes WordPress … Read more

How to get the name of the parent menu if the current page is an archive page in a custom menu

https://stackoverflow.com/questions/52006212/how-to-get-current-page-menu-item-ancestor-name-wordpress I found a solution through the answers to the above questions. function my_menu_parent($theme_location) { $locations = get_nav_menu_locations(); if ( isset( $locations[ $theme_location ] ) ) { $menu = wp_get_nav_menu_object( $locations[ $theme_location ] ); $menu_items = wp_get_nav_menu_items($menu->term_id); _wp_menu_item_classes_by_context( $menu_items ); $breadcrumbs = array(); foreach ( $menu_items as $menu_item ) { if ($menu_item->current_item_ancestor) { $breadcrumbs[] = … Read more

Can I insert elements anywhere into the results of wp_nav_menu()?

If you have control over the the wp_nav_menu() call, you can implement a custom Walker_Nav_Menu class for fine-grained control over the rendering of an array of nav menu items to HTML. If the markup of the items you wish to add is the same as that which the default Walker_Nav_menu already produces, you can use … Read more