Thursday, December 1, 2022
HomeWordPress Developmentphp - Learn how to add totally different menu objects on totally...

php – Learn how to add totally different menu objects on totally different menus?


This may occasionally sound bizarre, however I would like so as to add totally different menu objects to 2 particular menu sorts. Once I imply totally different menu objects, I imply, the objects I set to fundamental (header) menu are just for that menu and the identical factor for footer menu. So, the menu objects from primary-menu should not seem on secondary-menu and vice-versa, regardless of how comparable they appear to be.

  add_filter('wp_nav_menu_items', 'register_primary_menu_items', 10, 2);
  if (!function_exists('register_primary_menu_items')) {
    operate register_primary_menu_items($objects, $args) {
      if ( $args->menu = 'primary-menu' ) {
        $objects .= "n" . "tttttt" . '<li><a href="#house">Dwelling</a></li>' . "n" .
                 "tttttt" . '<li><a href="#fundamental">Who're We</a></li>' . "n" .
                 "tttttt" . '<li><a href="#service">Companies</a></li>' . "n" .
                 "tttttt" . '<li><a href="#contact">Contacts</a></li>' . "n";
          //return $objects;
      }
    /*
    if ( $args->theme_location = 'secondary-menu' ) {
        $objects="<li><i class="fa fa-angle-right"></i><a href="#house">Dwelling</a></li>" . "n" .
                 '<li><i class="fa fa-angle-right"></i><a href="#fundamental">Who're We</a></li>' . "n" .
                 '<li><i class="fa fa-angle-right"></i><a href="#service">Companies</a></li>' . "n" .
                 '<li><i class="fa fa-angle-right"></i><a href="#contact">Contacts</a></li>';
        return $objects;
      }*/
        
      return $objects;
    }
}

add_filter('wp_nav_menu_items', 'register_secondary_menu_items', 10, 2);
if (!function_exists('register_secondary_menu_items')) {
    operate register_secondary_menu_items($objects, $args) {
        if ( $args->menu = 'secondary-menu' ) {
            $objects = "n" . "tttttt" . '<li><i class="fa fa-angle-right"></i><a href="#house">Dwelling</a></li>' . "n" .
                     "tttttt" . '<li><i class="fa fa-angle-right"></i><a href="#fundamental">Who're We</a></li>' . "n" .
                     "tttttt" . '<li><i class="fa fa-angle-right"></i><a href="#service">Companies</a></li>' . "n" .
                     "tttttt" . '<li><i class="fa fa-angle-right"></i><a href="#contact">Contacts</a></li>' . "n";
            //return $objects;
          }
        return $objects;
    }
}

That’s the code I am presently utilizing, but it surely would not do what I need. As a substitute it units the identical menu objects from secondary-menu on each header and footer menu or the inverse.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments