New answers tagged

0

I ended up solving this problem with Ubermenu. What I wanted to write was complex enough that it made more sense to get a tested, commercial plugin that had the features I need. MaxMegaMenu didn't do tabbed content but Ubermenu does. I'm able to construct menus like this: Taxonomy1 [Tabs] [DynamicTerms] [Dynamic Posts] Taxonomy2 [Tabs] ...


4

Assuming you're using wp_nav_menu() to display your navigation you could apply a walker that looks for css classes: $items_wrap = '<nav class="...">'; $items_wrap .= '<ul id="%1$s" class="%2$s">%3$s</ul>'; $items_wrap .= '</nav>'; wp_nav_menu( array( 'container' => false, 'container_class' => false, ...


1

The default Wordpress themes, from Twenty Eleven onwards, support varying degrees of responsive design, including menus, and any child themes will automatically inherit this behaviour, unless the child theme does something to override it. It is possible to create menus in your theme using wp_nav_menu that can then be hidden or displayed for various screen ...


0

Well guys i post answet for anybody interested! I edited mr_permissions_roles_admin_page_restriction function because i noticed one thing: the restrictions i save are URL! so well here it is: function mr_permissions_roles_admin_page_restriction($screen) { $block=FALSE; $url=str_replace('/wp-admin/','',$_SERVER['REQUEST_URI']); global $menu; ...


0

As I edited above, I found the answer myself. Just use: $item->menu_order


0

Just to answer the direct question of where you might hook in to add to your nav menu, this technique is all over the web, mainly in the context of appending a search box to the nav. If the theme location for your menu is main-nav then this will add an extra list item to the menu list items. add_filter('wp_nav_menu_items', 'add_signup_form', 10, 2); ...


0

Jan mentioned nav_menu_css_class filter, so I looked it up and this example was helpful to me Source: https://codex.wordpress.org/Plugin_API/Filter_Reference/nav_menu_css_class function my_special_nav_class( $classes, $item ) { if ( is_single() && $item->title == 'Blog' ) { $classes[] = 'special-class'; } return $classes; } ...


1

If you want WordPress to add these items dynamically you would need to add a custom walker class to your menu declaration. Find where your menu is declared in the theme and add a custom walker class name in their wp_nav_menu function: wp_nav_menu( array ( 'menu'=> 'main-menu', 'container'=> '', 'walker' => new Description_Walker)); The menu may ...


1

Yes, you need to add this: add_action( 'init', 'my_custom_menus' ); function my_custom_menus() { register_nav_menus( array( 'primary-menu' => __( 'Primary Menu' ), 'secondary-menu' => __( 'Secondary Menu' ) ) ); } to your functions.php. It will create the menu locations in the menu admin area. More info: ...


2

You have to revise and reorder your code structure. Your site loads 27 render-blocking javascript files and 33 CSS files before the content above the fold. Also you load some plugin content before the styles are applied. Try to defer the blocking CSS and JS. Load everything early that is needed to display the first visible content (=above the fold) and ...


1

The left padding will be the default 40 pixels added to a ul by the browser. When I style WP menus I use this to make sure all browsers are happy: .blog-nav li, .blog-nav ul { padding: 0; margin: 0; }


0

You can use the global variable $submenu. Example to list the child menu of parent post menu:- function admin_init_callback() { global $submenu; $sumenu_list = $submenu['edit.php']; var_dump($sumenu_list); //array of submenu } add_action('admin_init', 'admin_init_callback', 999); Profi660 EDIT: Not needed to be used with admin_init hook. I ...


0

WordPress has a fairly good roles and capabilities system already and, IMHO, you'd find it easier working with that. When the admin menu is constructed, every item on the admin menu is subject to a check on a relevant capability. Similarly every attempt to use an admin screen is checked. It's possible to use map_meta_cap to rework some of these ...


0

Simple Method First thing you need to do is add a new menu item in your menu. You can do that by going to Appearance » Menus. You want to add a custom link so give it the label you want. In the URL field, enter the # sign. Once done, click on the Add to Menu button. Save your menu once this custom link is added to the menu. Adding a custom link to the menu ...


0

I am not sure how it does effect the SEO but just to answer this question:- You can not save menu item with javascript:void(0); because WordPress filter the URL using function esc_url() thus removing bad values. And it all happens in Nav Walker class. So you need to alter the URL when WordPress done with filtering and returning final safe HTML. You ...


2

I think @Milo's comment is correct. Presumably you want to use functions like current_user_can(), etc. Alternatively, if this is just to show a different menu, you could create a custom menu for remote users then set a cookie on your wordpress site (via a call from the API) and display a different menu to your remote users when authenticated remotely. ...


0

@Dan meant this: <nav role="navigation" itemscope="itemscope" itemtype="http://schema.org/SiteNavigationElement"><?php wp_nav_menu([ 'container' => '', 'items_wrap' => '<ul>%3$s</ul>', ... ]); ?></nav>


1

You can use a built in function of the menu editor for this. Go to your Custom Post Type in the Menu editor, click the "view all" tab and the first item you see is a link to the CPT archive page.


3

As @toscho said, you can call the walker class with parameters as you did: new BEMwalker( 'mobile' ) The constructor of BEMwalker will take the arguments (like any other function or method in PHP) so you can access the parameter(s) via $this: class BEMwalker extends Walker_Nav_Menu { private $classes; public function __construct( $classes = '' ...


0

In your example, the 'Key Industries' page appears to be a different page under each of those top level menus - or at the very least, the URL is different. This most likely allows their CMS to differentiate and use the correct submenu. Here's what I do when I want to achieve this: Hook into wp_nav_menu_objects and check for a custom submenu argument, ...


0

Found a way... instead of using wp_nav_menu() $menu_name = 'main-menu'; if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) { $menu = wp_get_nav_menu_object( $locations[ $menu_name ] ); $menu_items = wp_get_nav_menu_items($menu->term_id); $menu_list = '<ul id="menu-main-menu">'; foreach ( ...



Top 50 recent answers are included