Tag Info

Hot answers tagged

7

There even is a way to make this possible with CSS alone. This has some limitations, but I still thought it might be an interesting approach: Limitations You need to hardcode the width of the dropdown Browser-Support. You basically need CSS3 selectors. But everything from IE8 up should work, although I haven't tested this. This is more of a ...


6

Using a custom Walker, the start_el() method has access to $depth param: when it is 0 the elemnt is a top one, and we can use this info to maintain an internal counter. When the counter reach a limit, we can use DOMDocument to get from full HTML output just the last element added, wrap it in a submenu and add it again to HTML. Edit When the number of ...


6

You can use wp_nav_menu_items filter. It accepts menu output and arguments which hold menu attributes, like menu slug, container, etc. add_filter('wp_nav_menu_items', 'wpse_180221_nav_menu_items', 20, 2); function wpse_180221_nav_menu_items($items, $args) { if ($args->menu != 'my-menu-slug') { return $items; } // extract all ...


4

Got a working function, but not sure if it is the best solution. I used a custom walker: class Custom_Walker_Nav_Menu extends Walker_Nav_Menu { function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { global $wp_query; $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; $classes = empty( $item->classes ) ? ...


2

I've asked this question a bit to early, but to help others in the feature here's the solution. For the menu editor to appear, you need to register a menu first: add_action( 'init', 'register_header_menu' ); function register_header_menu() { register_nav_menu('header-menu',__( 'Header Menu' )); } Or as pointed out by Howdy_McGee: add_theme_support( ...


2

As far as I've seen you're missing bootstrap CSS grid markup inside your page div, so to start add container class to page div and below that a .row element, for more inforamation on how the Bootstrap grid works check documantation and remember that all Js and styles are based on the correct markup selectors_


2

What about setting a static page as a page for posts? Settings -> Reading -> Front Page displays One static page for front (for example Home) and another static page (Blog) for posts.


1

I had a very similar issue. I needed to target a specific wp_nav_menu() and replace the a links with a class. Here is my solution in reference to the OP: function theme_add_menuclass( $classes, $args ) { if ( $args->theme_location == 'your-menu-location' ) { return preg_replace( '/<li /i', '<li class="your-class"', $classes ); } ...


1

Query parsing happens on every query run on a page, not just the main query. Your parse_tax_query is modifying the query for menu items in your menu. Check is_main_query() to make sure you only change the main query: function no_child_terms($query) { if( !is_admin() && $query->is_main_query() ){ ...


1

You may be able to use a WP_Query on nav_menu_item since it is its own post type. I've never done this but maybe it would work like you need it to, worth a shot. There are three other possibilities: Option 1 - Get Your Nav Menu Items There's a functions called wp_get_nav_menu_items() which will return you an array of your menu items that you can then loop ...


1

Unfortunately is_category() not worked for me but if(in_category( 'articles' )) `in_category()` worked Codex reference for in_category().


1

Here a very quick example. The idea is to add a new meta box in the menu configuration. add_meta_box is used in admin_head-nav-menus.php page: class Custom_Nav { function __construct() { add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) ); } public function add_nav_menu_meta_boxes() { add_meta_box( ...


1

When you create a menu, after adding your pages to it, and after saving once, you have to check the box at the bottom on the page to tell wordpress on which menu area of your theme you would like to add the menu. You can also assign menus in appearrance -> customize.


1

My solution to this problem when extending the Walker_Nav_Menu was to skip check if current_page_parent when C.P.T. I identified C.P.Ts following this stackexchange post. This does not entirely solve the problem as I am using current_page_item for C.P.T parent menu items, but it does achieve the desired outcome. Here is my class. class My_Menu extends ...


1

I believe that this plugin will do what you want. Jamocreations Auto Submenu https://wordpress.org/plugins/auto-submenu/ Here is also a link to the author's site, http://jamocreations.com/en/artikelen/auto-submenu , where he discusses why he built the plugin and also two other plugins that also work similarly. The advantage of the Jamocreations Auto ...



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