New answers tagged

0

.menu-home-container { position: relative; top: 40px; } .header_mid_inner .search_wrap { position: relative; top: 40px; } .header_top_inner .meta_wrap { top: 58px; position: absolute; right: 0; z-index: 2; }


0

The default fallback in wp_nav_menu for a menu that doesn't exist/isn't registered is wp_page_menu, which unfortunately does not support the same arguments/implement the same level of "customisability" - you either need to create a custom fallback, or remove the fallback entirely (so that the user is forced to set a menu).


0

Alright so this isn't too difficult, first we will just check if the menu item is a taxonomy then get the count and display it! function ggstyle_menu_item_count( $output, $item, $depth, $args ) { // Check if the item is a Category or Custom Taxonomy if( $item->type == 'taxonomy' ) { $object = get_term($item->object_id, $item->...


0

Guessing the only way you get it without loop through the menu, is getting the post meta directly. Navigation menus are saved as custom post type into wp_posts, so you can get it with get_posts or get_post_meta. If it's a custom link menu item, the code below should do it. Where $menu_id is you menu item id. get_post_meta($menu_id, '_menu_item_url', true)...


0

Yes it is possible, please take a look at the code below it will give you the basic idea. You can change ul to div and add some logic to match your needs. $menu_name = 'primary'; $menu = wp_get_nav_menu_object( $locations[ $menu_name ] ); $menu_items = wp_get_nav_menu_items($menu->term_id); $menu_list = '<ul id="menu-' . $menu_name . '">'; foreach (...


0

How about just go to the menu from wp-admin remove product menu(i.e the current one) now create a new menu (Product)using Custom Menu and put url to # and add ur sub menus, if u have different class for current menu u can add custom class too follow these steps In Appearance > Menus, click the Screen Options tab. Under Show advanced menu properties, check ...


0

Personnaly, I prefer use filters to manipulate data before menu generation. Example with wp_setup_nav_menu_item: add_filter('wp_setup_nav_menu_item', function($menu) { $menu->url = ""; return $menu; }); This filter is ran on each retrieved menu item but without nowing which menu is currently processed. Another example with ...


0

If you want to do this with PHP then use a custom walker and targeting the menu directly (if is menu item xxx), but jQuery will do this easily for you using removeAttr $("#menu-item-xxx"). removeAttr("href"); That won't remove the tag, just removes the href="" from the tag.


0

There are two possible approaches you can take. One would be to hook into whenever a Page is published and write code to update the menu accordingly, effectively making something similar to the built-in "add top level pages" functionality. You'd need to think carefully about what you would like to happen when the Page parent is changed and so on. So ...


2

Counter - Inside Menu Links You can e.g. use the nav_menu_item_titleCodex filter to adjust the menu titles: add_filter( 'nav_menu_item_title', function( $title, $item, $args, $depth ) { static $instance = 0; // Append an increasing counter to the menu title for menu items // within a given menu location and menu class if( 'my-custom-...


1

If you will not pass that how many arguments you need in your callback function then add_filter will provide you only one and first argument. Because default arguments for add_filter are add_filter ( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 ); $accepted_args is 1 if you do not pass it. Thus $args is always ...


2

That edit explains it. Alphabet is poorly written. Its use of php's include rather than WordPress's own include functions like get_header and get_template_part is breaking the parent/child hierarchy. You could probably make a copy of the file header.php and change those includes, as long as the file calling in header.php does it correctly! As long as ...


1

Within the header, modify the wp_nav_menu code to include: 'items_wrap' => '<ol id="%1$s" class="%2$s">%3$s</ol>', Full Menu Code <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu', 'items_wrap' => '<ol id="%1$s" class="%2$s">%3$s</ol>' ) ); ?>


1

'items_wrap' (string):How the list items should be wrapped. Default is a ul >with an id and class. Uses printf() format with numbered placeholders. Default items_wrap is <ul id="%1$s" class="%2$s">%3$s</ul> You can pass items_wrap argument to the wp_nav_menu like this. wp_nav_menu( array( 'theme_location' => 'primary', '...


2

You certainly could build a custom walker, but perhaps the easiest way out is jquery: $("li.active").parent().addClass("is-active");


0

Start by browsing to Appearance – Menus. Select the menu where you want the link to be displayed. Create a new Link menu item and use # as the URL with the link text of categories. Then click the Add to Menu button. Select which categories you want to be displayed within the dropdown list. After you add the categories to the menu, make sure to drag and ...


1

What you're getting is an array so you need to implode() them - the Walker_Nav_Menu has something like this: $class_names = esc_attr( implode( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ) ); So you can modify your foreach to implode them in a similar fashion $class = esc_attr( implode( ' ', apply_filters( '...


0

I sort of added onto @Giri's answer by using array_map and array_count_values. if this helps anyone in the future. I didn't wish to use a counter and a foreach loop for something so simple. function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { if ($item->hasChildren) { $locations = get_nav_menu_locations(); // ...


0

Hi thx for your answering ,but i confused shall I define one of stdclass objects like [menu] => Menu Name or [theme_location] => İf so,Is it neccessary to change Menu Name which on you typed [menu] => Menu Name Could u send me hole ordered codes,pls?


-1

Use following code as jQuery: jQuery('#nav li').removeClass('current'); jQuery('#nav>li.current-menu-item').addClass('current'); jQuery('.has-children li.current-menu-item').closest('.has-children').addClass('current'); See jsfiddle (current item red color). When you click "Single Blog" menu item your html structure will like my following example and ...


2

This is panel not section so remove_section() will not work in this case. However you can use function remove_panel() but it will trigger a notice saying Notice: WP_Customize_Manager::remove_panel was called incorrectly Removing nav_menus manually will cause PHP warnings. Use the customize_loaded_components filter instead. Please see Debugging in ...


1

This is offtopic, but since I'm in a good mood with the weekend coming up I'll answer you anyway ;-) The problem is there because the menu you have chosen to use on the page is meant for links that scroll down on the same page. Therefore a piece of javascript is included by the theme that disables normal link behaviour in favour of scrolling. But since the ...


2

The wp_nav_menu_items filter has a secondary parameter that it passes: $args. What we need to do is set up our filter to accept second args by passing a priority 10 and the number of args 2: add_filter( 'wp_nav_menu_items', 'my_counter_nav_menu', 10, 2 ); Now that we're passing args - if we peek into what it holds we see the following object: stdClass ...


2

In order to downgrade your wp version , first download your desired version from the link below https://wordpress.org/download/release-archive/ Then follow the steps Deactivate all plugins Logout of wordpress Delete the WP-ADMIN WP-INCLUDES folders via FTP Transfer the files from the downngraded wp version to your site via FTP EXCEPT WP-CONTENT Now ...


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



Top 50 recent answers are included