current-menu-item class in CSS

I have created one main Page(Home Page) and many custom links in wp-admin. All custom links are linked to sections of Home Page. Example: Custom link About Us has a URL = #section1 and in my code I have linked it to: <div id="section1"> Text </div> In my CSS I have used .current-menu-item to highlight clicked link in menu: .site-header div.nav-wrap nav ul li.current-menu-item a:link, .site-header div.nav-wrap nav ul li.current-menu-item a:visited { color: #fff; text-shadow: -1px 1px 8px #ffc, 1px …
Category: Web

list category posts under its item in menu

When adding category to Menu, I need it to list all the item that belong to that category in separate UL automatically. like this http://i.stack.imgur.com/ulOOS.jpg Of course I can do that manually, but I'm look for a way to add a filter, maybe, to the wp page menu function, but Im not sure how its can be done. I'm using thematic child theme Thank you.
Category: Web

wp_nav_menu displaying all pages

As the title says, I'm using wp_nav_menu in header.php to load in the audience, secondary, and main menus and when I do, every menu contains every page - or at least many more pages than I selected for the menus. I'm having the hardest time trying to make this work for some reason, so any help is appreciated. Here's the code to register the menus in functions.php: // WordPress Menu Locations function diviecommerce_setup() { register_nav_menus(array( 'primary' => esc_html__( 'Main Menu', …
Category: Web

Menu custom link not working for external site

I've got this header menu in my site (made editing a theme), but i've noticed that the custom links pointing at local anchor section (like #section) correctly navigate in the same page to the desired location, but an external link won't work, even if specifing "open in new tab". I suppose something is preventing the menu link to open, or worse, the external link is not supported in that theme. Since i'm noob, where should i look for the menu …
Category: Web

Add image to menu item with ACF

I'm trying to add an image to menu item, can't get it to work. Here is my code. header.php <?php wp_nav_menu( array( 'theme_location' => 'side-menu', 'container_class' => 'fixed-menu', 'fallback_cb' => '', 'link_before' => '<span>', 'lnk_after' => '</span>', 'depth' => 2, 'walker' => new Understrap_WP_Bootstrap_Navwalker(), ) ); ?> And here is the function.php // Header Side Menu function etm_side_menu() { register_nav_menu('side-menu',__( 'Header Side Menu' )); } add_action( 'init', 'etm_side_menu' ); add_filter('wp_nav_menu_objects', 'wp_nav_menu_objects', 10, 2); function wp_nav_menu_objects( $items, $args ) { // …
Category: Web

Add Featured Image and Title to wp_nav_menu items

I like this solution from Ahmad M, a lot, but how do I add images in addition to titles, instead of replacing titles? (Sorry, I'm still pretty new to PHP and Stackexchange). Pulling Featured Images in to a WordPress Menu I mostly figured it out. I'm using Ahmad M's filter but needed to add ".$menu_object->title" to the thumbnail so now it looks like: $menu_object->title = has_post_thumbnail($menu_object->object_id) ? get_the_post_thumbnail($menu_object->object_id, 'full') . $menu_object->title . : $menu_object->title; Now my challenge is that I …
Category: Web

Wordpress menu walker - help to add custom class for each submenu

I am trying to apply to my already existing menu a walker in order to add custom classes to every sub menu anchor tag. Here is my menu: wp_nav_menu(array( 'theme_location' => 'menu-top', 'container' => 'ul', 'menu_class' => 'header_nav_ul', 'menu_id' => 'header_nav_id', 'depth' => 0, )) I added the wolder and it became: wp_nav_menu(array( 'theme_location' => 'menu-top', 'container' => 'ul', 'menu_class' => 'header_nav_ul', 'menu_id' => 'header_nav_id', 'depth' => 0, 'walker' => new my_walker_nav_menu_start_el(), )) The walker function is this one: function …
Category: Web

How to disable permalink of a particular menu item?

I'm using WordPress Twenty Sixteen theme. Now I've a menu item named Product and it has a sub menu. The product page has a permalink as usual, but I want to remove it i.e., when I click on this menu item, it shouldn't perform any action, just like clicking on a text. However, it should not lose its hover color while doing so. I found a solution pointer-events: none, but it removes the hover color. I don't want to use …
Category: Web

Dynamically add sub menu items

I have been able to add menu items with this statement, this however creates a flat menu. The menu has been created already. I just need to add items. wp_update_nav_menu_item(4, 0, array('menu-item-title' => __($post_title), 'menu-item-url' => home_url('/'.$url.'/'), 'menu-item-status' => 'publish')); this is super simple to use. How do I add a sub-menu item?
Category: Web

Hide product categories and taxonomy terms in menu if empty

I've been researching this and had no luck so far. I have a WooCommerce store with a main menu showing product categories (product_cat) and brands (yith_product_brand) which is a custom taxonomy. I want to hide categories and brands if they are empty. Do you know a way to achieve this, either by using a plugin or adding a function/filter to the functions.php file? If so any help would be much appreciated. Thanks in advance.
Category: Web

WordPress custom menu can't show 3. level submenu

I Use a custom walker from my menu in WordPress and my menu doesn't show all levels. https://soulofcroatia.com/ ->One Day menu item. This is my code in header.php <?php wp_nav_menu( array( 'theme_location' => 'mainmenu', 'menu' => 'mainmenu', 'container' => 'ul', 'container_class' => 'collapse navbar-collapse', 'container_id' => 'navbarCollapse', 'menu_class' => 'nav-list', 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'items_wrap' => '<ul class="%2$s">%3$s</ul>', 'depth' => 3, 'walker' => new Primary_navigation_walker(), ) ); ?> this is my code in custom-walkers.php class Primary_navigation_walker extends Walker_Nav_Menu …
Category: Web

How to display dynamic content in start_lvl function

I am creating a custom nav walker but having trouble outputting parent menu item title in start_lvl function. I want to output it right after the <div class="dropdown"> in the following start_lvl function. function start_lvl(&$output, $depth = 0, $args = array()) { $indent = str_repeat("\t", $depth); if ($depth == 0) { $out_div = ' <div class="dropdown-wrapper"><div class="dropdown">This is where I want to output parent item title'; } else { $out_div = ''; } // build html $output.= "\n" . $indent …
Category: Web

WordPress Settings API, Implementing Tabs On Custom Menu Page

I've been following the WordPress Settings API tutorial series of this guy: http://wp.tutsplus.com/tutorials/theme-development/the-complete-guide-to-the-wordpress-settings-api-part-1/ So far, I've been successful at doing the basic thing. Now, when implementing tab, I'm facing problem. Problem 1: The Tabs are not working. All the fields are being displayed on both the tabs. Section 1, should be displayed on Tab One and Section 2 on Tab Two. Problem 2: Option 2 is not being saved. It was working fine before implementing tabs. Code: /* ----------------------------------------------------------------------------- */ …
Category: Web

How do I convert a custom menu wp_get_nav_menu_items into Fourth level?

how can I turn this function from Two-level into the Fourth level in WordPress? This function can only echo the parent and its child, but I'm trying to make it unlimited or at least 4 levels if it is possible A B -2 C -2 -3 -- Not Work -4 -- Not Work D -2 F this is my code: it works only till level 2 function wp_get_menu_array($current_menu) { $array_menu = wp_get_nav_menu_items($current_menu); $menu = array(); foreach ($array_menu as $m) { …
Category: Web

Add Product categories to Wordpress menu without losing hierarchy

I need to add product categories to Wordpress menu, but when I'm doing this with WP interface it lose the hierarchy I tried with WP-CLI, but there is no method to specify wich item is the child. There is a method to do it? There is a ton of categories (3-4 level deep), I cannot do this manually I can buy also a plugin. Can you suggest something? Thanks a lot
Category: Web

Multiple languages menus problem

I'm trying to add language option to my website. I've coded my theme and I need to show the web in three different languages. I've got the little flags and I've managed to pass a php variable with the language it's selected. With that variable I've made a if for the wp_nav_menu assignment in the header.php. It works actually. When I change the language the correct menu in the correct language comes up. The problem is that when I hit …
Category: Web

Sub Categories in drop down menu

I have lot of categories and sub categories. I want to add all these in WordPress menu. But i want to add subcategories aligned properly under their parent categories without drag and drop each and every time. Right now when i select all menus from categories these does not aligned under their parent category.Is there any automated way to do this so it will save my lot of my time? Your help will be much appreciated.
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.