Hot answers tagged

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, ...


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 = '' ...


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. ...


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 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 ...


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: ...


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; }


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.



Only top voted, non community-wiki answers of a minimum length are eligible