<?php
//$locations = get_nav_menu_locations();
$theme_location = "primary";
// if there's a location for the primary menu
if ( ($theme_location) && ($locations = get_nav_menu_locations()) && isset($locations[$theme_location]) ) {
$menu = get_term( $locations[$theme_location], 'nav_menu' );
//$menu = get_term( $locations['primary-menu'], 'nav_menu');
// if there are items in the primary menu
if ( $items = wp_get_nav_menu_items( $menu->name ) ) {
// loop through all menu items to display their content
foreach ( $items as $item ) {
// if the current item is not a top level item, skip it
if ($item->menu_item_parent != 0) {
continue;
}
// get the ID of the current nav item
$curNavItemID = $item->ID;
// get the custom classes for the item
// (determined within the WordPress Appearance > Menu section)
$classList = implode(" ", $item->classes).' new-nav';
echo "<li class=\"{$classList}\">";
echo "<a href=\"{$item->url}\" class=\"main-nav-items\">{$item->title}<div class=\"nav-pointer about-pointer\"></div></a>";
// build the mega-menu
// if 'mega-menu' exists within the class
if ( in_array('mega-drop-down', $item->classes)) { ?>
<div class="animated fadeIn mega-menu">
<div class="mega-menu-wrap">
<div class="row">
<div class="col-md-12 bg-nav-white"></div>
<?php
//display for solutions
if(in_array('solutions', $item->classes)){
?>
<div class="col-md-12 col-lg-6 set-pad-left-40 set-pad-top-20">
<ul class="solutions-list">
<?php // cycle through the menu items and get the subnav
foreach ( $items as $subnav) {
if ( $subnav->menu_item_parent == $curNavItemID) {
?>
<li>
<h4 class="row mega-title mob-as-link-mns dropdown">
<a href="<?php echo $subnav->url; ?>">
<?php
if(in_array('nav-uccs', $subnav->classes)){ //set the icon position for "unified communication..."
$cssclass = 'style="padding-top: 6px;"';
}else{
$cssclass = '';
}
?>
<span <?php echo $cssclass?>>
<img src="<?php bloginfo('stylesheet_directory');?>/assets/images/icons/<?php echo $subnav->classes[0]; ?>.png" alt=""></span>
<?php echo $subnav->title; ?> <?php //echo $subnav->ID; ?><i class="fa fa-angle-right" aria-hidden="true"></i>
</a>
</h4>
<?php //echo"<pre>";print_r($subnav);echo"</pre>";?>
<?php
if(in_array('nav-mns', $subnav->classes)){
$page_id = 666;
}elseif(in_array('nav-mcs', $subnav->classes)){
$page_id = 687;
}elseif(in_array('nav-uccs', $subnav->classes)){
$page_id = 133;
}elseif(in_array('nav-mss', $subnav->classes)){
$page_id = 720;
}elseif(in_array('nav-ps', $subnav->classes)){
$page_id = 143;
}
?>
<ul class="stander mob-stander-mns">
<?php
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
'post_parent' => $page_id,
'order' => 'DESC',
'orderby' => 'menu_order'
);
$parent = new WP_Query( $args );
if ( $parent->have_posts() ) : ?>
<?php while ( $parent->have_posts() ) : $parent->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<!-- level 3 subpage -->
<?php
$args_ = array(
'post_type' => 'page',
'posts_per_page' => -1,
'post_parent' => $post->ID,
'order' => 'DESC',
'orderby' => 'menu_order'
);
$parent_ = new WP_Query( $args_ );
if ( $parent_->have_posts() ) : ?>
<?php while ( $parent_->have_posts() ) : $parent_->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>">» <?php the_title(); ?></a>
</li>
<?php endwhile; ?>
<?php endif; wp_reset_postdata(); ?>
<!-- end level 3 subpage -->
<?php endwhile; ?>
<?php endif; wp_reset_postdata(); ?>
</ul>
</li>
<?php }
} ?>
</ul>
</div>
<div class="col-md-4 col-lg-6 bg-mega-menu d-none d-sm-block d-sm-none d-md-block">
<h4 class="row mega-title"><?php if($currLang == "id-ID"){?>Managed Solutions Kami<?php }else{ ?>Our Managed Solutions<?php } ?></h4>
<p><?php echo $item->description; ?></p>
<a href="<?php echo $item->url; ?>" class="learn-more">Find Out More</a>
</div>
<?php }else if(in_array('insights', $item->classes)){
//display for about us menu
?>
<div class="col-lg-6 mega-menu_subnav">
<ul class="inline-list">
<?php // cycle through the menu items and get the subnav
foreach ( $items as $subnav) {
if ( $subnav->menu_item_parent == $curNavItemID) {
$classList = implode(" ", $subnav->classes);
echo "<li class=\"{$classList}\"><a href=\"{$subnav->url}\">{$subnav->title}</a></li>";
}
} ?>
</ul>
</div>
<div class="col-md-6 bg-mega-menu d-none d-sm-block d-sm-none d-md-none d-lg-block">
<h4 class="row mega-title"><?php if($currLang == "id-ID"){?>Insight Terkini<?php }else{ ?>Latest Insight<?php } ?></h4>
<?php
// the query
$the_query = new WP_Query( array(
'posts_per_page' => 1,
));
?>
<?php if ( $the_query->have_posts() ) : ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php the_title(); ?>
<?php tn_custom_excerpt_length(the_excerpt()); ?>
<?php //wpshout_change_and_link_excerpt(the_excerpt());?>
<?php //the_excerpt(); ?>
<a href="<?php the_permalink($main_id); ?>">» read more</a>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php __('No News'); ?></p>
<?php endif; ?>
</div>
<?php }else if(in_array('aboutus', $item->classes)){
//display for about us menu
?>
<div class="col-lg-6 mega-menu_subnav">
<ul class="inline-list">
<?php // cycle through the menu items and get the subnav
foreach ( $items as $subnav) {
if ( $subnav->menu_item_parent == $curNavItemID) {
$classList = implode(" ", $subnav->classes);
echo "<li class=\"{$classList}\"><a href=\"{$subnav->url}\">{$subnav->title}</a></li>";
}
} ?>
</ul>
</div>
<div class="col-md-6 bg-mega-menu d-none d-sm-block d-sm-none d-md-none d-lg-block">
<h4 class="row mega-title"><?php if($currLang == "id-ID"){ ?>Tentang telkomtelstra<?php }else{?>About Us<?php }?></h4>
<p><?php echo $item->description; ?></p>
<a href="<?php echo $item->url; ?>" class="learn-more">Learn More</a>
</div>
<?php } ?>
</div>
</div>
</div>
<?php } ?>
<?php
if ( in_array('single-drop-down', $item->classes)) {
?>
<div class="animated fadeIn mega-menu single-menu">
<div class="nav-pointer insights-pointer"></div>
<div class="mega-menu-wrap">
<div class="row">
<div class="col-md-12 bg-nav-white"></div>
<div class="col-lg-12 mega-menu_subnav">
<ul class="inline-list">
<?php // cycle through the menu items and get the subnav
foreach ( $items as $subnav) {
if ( $subnav->menu_item_parent == $curNavItemID) {
echo "<li><a href=\"{$subnav->url}\">{$subnav->title}</a></li>";
}
} ?>
</ul>
</div>
</div>
</div>
</div>
<?php } ?>
<?php
if ( in_array('search-drop-down', $item->classes)) { ?>
<div class="animated fadeIn mega-menu search-form-desk" >
<!-- <div class="nav-pointer about-pointer"></div> -->
<div class="mega-menu-wrap">
<div class="row">
<div class="col-md-12 bg-nav-white"></div>
<div class="col-md-12 center text-center search-form-drop">
<form action="http://projects.guntur-gr.com/telkomtelstra/en/" role="search" method="get" id="searchform">
<div class="form-group cus-search">
<input class="form-control-lg" type="text" placeholder="Explore telkomtelstra..." name="s" id="s" value="">
<button type="submit" class="btn btn-search"><i class="fa fa-search"></i></button>
</div>
</form>
</div>
</div>
</div>
</div>
<?php } ?>
<?php
// if this is the search bar
if ( in_array('nav-search', $item->classes) ) { ?>
<form action="<?php echo esc_url( home_url( '/' ) ); ?>" role="search" method="get" id="searchform" >
<div class="form-group cus-search mobile-search">
<input class="form-control-lg" type="text" placeholder="Explore telkomtelstra..." name="s" id="s" value="">
<button type="submit" class="btn btn-search"><i class="fa fa-search"></i></button>
<?php //get_search_form(); ?>
</div>
</form>
<?php }
echo '</li>';
}
}
} ?>
description:
Dynamic Mega menu style main navigation, you can setup in Appearance > Menu
