• Hi,

    I am trying to remove an old link named ERBJUDANDEN but it is still visible on my website, even thou its not visible in the list of the menu, see picture below. Any sugestions?

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi @vimpan,

    I think it’s added using the wp_nav_menu_items hook. Please check your functions files and you can comment the hook. Thanks!

    Thread Starter vimpan

    (@vimpan)

    @ashish121 I am sorry but I cant understand where I find this

    • This reply was modified 1 year, 1 month ago by vimpan.

    @vimpan, please review the functions.php file. You can locate it using the following path within your directory: wp-content/themes/>active-theme>/functions.php.

    Thread Starter vimpan

    (@vimpan)

    In that file I have this;

    <?php
    /**

    • Roots includes
      *
    • The $roots_includes array determines the code library included in your theme.
    • Add or remove files to the array as needed. Supports child theme overrides.
      *
    • Please note that missing files will produce a fatal error.
      *
    • @link https://github.com/roots/roots/pull/1042
      */
      $roots_includes = array(
      ‘lib/utils.php’, // Utility functions
      ‘lib/init.php’, // Initial theme setup and constants
      ‘lib/wrapper.php’, // Theme wrapper class
      ‘lib/sidebar.php’, // Sidebar class
      ‘lib/config.php’, // Configuration
      ‘lib/activation.php’, // Theme activation
      ‘lib/titles.php’, // Page titles
      ‘lib/nav.php’, // Custom nav modifications
      ‘lib/gallery.php’, // Custom [gallery] modifications
      ‘lib/scripts.php’, // Scripts and stylesheets
      ‘lib/extras.php’, // Custom functions
      );

    foreach ($roots_includes as $file) {
    if (!$filepath = locate_template($file)) {
    trigger_error(sprintf(__(‘Error locating %s for inclusion’, ‘roots’), $file), E_USER_ERROR);
    }

    require_once $filepath;
    }
    unset($file, $filepath);

    Thread Starter vimpan

    (@vimpan)

    in the nav.php i have this;

    <?php
    /**

    • Cleaner walker for wp_nav_menu()
      *
    • Walker_Nav_Menu (WordPress default) example output:
    • Home
    • Sample Page</l
      *
    • Roots_Nav_Walker example output:
    • Home
    • Sample Page
    • Remove the id=”” on nav menu items
    • Return ‘menu-slug’ for nav menu classes
      */
      function roots_nav_menu_css_class($classes, $item) {
      $slug = sanitize_title($item->title);
      $classes = preg_replace(‘/(current(-menu-|[-]page[-])(item|parent|ancestor))/’, ‘active’, $classes);
      $classes = preg_replace(‘/^((menu|page)[-_\w+]+)+/’, ”, $classes); $classes[] = ‘menu-‘ . $slug; $classes = array_unique($classes); return array_filter($classes, ‘is_element_empty’);
      }
      add_filter(‘nav_menu_css_class’, ‘roots_nav_menu_css_class’, 10, 2);
      add_filter(‘nav_menu_item_id’, ‘__return_null’);
    • Clean up wp_nav_menu_args
      *
    • Remove the container
    • Use Roots_Nav_Walker() by default
      */
      function roots_nav_menu_args($args = ”) {
      $roots_nav_menu_args = array(); $roots_nav_menu_args[‘container’] = false; if (!$args[‘items_wrap’]) {
      $roots_nav_menu_args[‘items_wrap’] = ‘
        ‘;
        } if (!$args[‘depth’]) {
        $roots_nav_menu_args[‘depth’] = 2;
        } return array_merge($args, $roots_nav_menu_args);
        }
        add_filter(‘wp_nav_menu_args’, ‘roots_nav_menu_args’);

      @vimpan, please add the below filter for unset the menu items in your functions.php file. I hope this solution works for you. ??

      function wp_unset_menu_items( $menu_objects, $args ) {
      
          if ( 'primary_menu' !== $args->theme_location ) {
              foreach ( $menu_objects as $key => $menu_object ) {
                  if ( $menu_object->title == 'Erbjudanden') {
                      unset( $menu_objects[ $key ] );
                      break;
                  }
              }
          }
      
          return $menu_objects;
      }
      add_filter( 'wp_nav_menu_objects', 'wp_unset_menu_items', 10, 2 );
      Thread Starter vimpan

      (@vimpan)

      I have pasted it in the functions.php but nothing changes in the menu on the site, any other idea?

      Great thanks for taking the time and helping!

    Viewing 7 replies - 1 through 7 (of 7 total)
    • The topic ‘Old link in meny unremovable’ is closed to new replies.