wp-nav menu with custom walker , how to remove a tag if it has any submenu
wp-nav menu with custom walker , how to remove a tag if it has any submenu
wp-nav menu with custom walker , how to remove a tag if it has any submenu
I don’t know if you need to hide the element completely, as in “never display it”, or if you need to hide it conditionally with JavaScript– say, to get a toggle effect. Either case is similar and would use get_post_meta(). To conditionally display the data use something like: $m = get_post_meta(get_the_ID(),’my_meta_key’); if(!empty($m)) { echo ‘<div>your … Read more
Thank you for our reply i solved my problem i used WordPress loop query for showing last fout posts in four column as below if (!empty($item->divideto_4)) { $col = 3; $divide_to = 12 / $col; //4 $my_query = “showposts = “.$divide_to; $my_query = new WP_Query($my_query); while ($my_query->have_posts()) : $my_query->the_post(); $item_output .= ‘<div class=”col-sm-‘.$col.'”>’; $item_output .= … Read more
Why does appear? I’m trying to remove a generic link called navigation on my main menu
You can not use WordPress functions outside your wordpress dir (wordpress core). Wordpress is a framework and you need to create pages based on the guidelines set by WP community. You need to create a proper WP page and than maybe use it on the other domain with iframe.
You can use the nav_menu_css_class filter to alter the classes added to navigation items. You need to check the current menu items URL against the URL of the page you are on. add_filter( ‘nav_menu_css_class’, ‘wpse_217882_menu_class’, 10, 2 ); function wpse_217882_menu_class( $classes = array(), $item = false ) { // Get current URL $current_url = wpse_217882_current_url(); … Read more
So this is the way I eventually achieved this. I put the following code into my functions.php (actually into the functions.php of my child theme to keep it safe from updates) It has just one change to the original code from the link in the question thanks to @birgire. /** * auto_child_page_menu * * class … Read more
You just need the third argument $args, of which one of it’s properties is theme_location: function wpse_218377_nav_menu_css_class( $classes, $item, $args ) { if ( ! empty( $args->theme_location ) && $args->theme_location === ‘custom-menu’ ) { $classes[] = ‘footer–menu-item’; } // ALWAYS return, not from inside the if return $classes; } add_filter( ‘nav_menu_css_class’ , ‘wpse_218377_nav_menu_css_class’ , 10, … Read more
Okay, figured it out! I’ve amended my theme function as follows: add_filter( ‘wp_nav_menu_items’, ‘add_loginout_link’, 10, 2 ); function add_loginout_link( $items, $args ) { if (is_user_logged_in() && $args->theme_location == ‘top_navigation’) { $items .= wp_nav_menu( array(‘menu’ => ‘menu-logged-in’, ‘container’ => ”, ‘echo’ => false, ‘items_wrap’ => ‘%3$s’) ); } elseif (!is_user_logged_in() && $args->theme_location == ‘top_navigation’) { $items … Read more
Has there been any improvements to wp’s menu handling?