Commit 3cc536ac authored by Simon's avatar Simon

Job categories fix

parent 4a371dc6
......@@ -125,19 +125,23 @@ get_header();
$occupationalCategories = get_the_terms( $ID, 'field' );
foreach ($occupationalCategories as &$occupationalCategory) :
if (is_array($occupationalCategories)) :
foreach ($occupationalCategories as &$occupationalCategory) :
?>
<meta itemprop="occupationalCategory" content="<?php echo $occupationalCategory->name ; ?>" />
<?php
endforeach;
endforeach;
endif;
$employmentTypes = get_the_terms( $ID, 'type' );
foreach ($employmentTypes as &$employmentType) :
if (is_array($employmentTypes)) :
foreach ($employmentTypes as &$employmentType) :
?>
<meta itemprop="employmentType" content="<?php echo $employmentType->name; ?>" />
<?php
endforeach;
endforeach;
endif;
?>
<ul class="c-categories">
<?php
......
<?php
// delog('', 'post');
// debug($post);
// delog($post->ID, 'post ID');
$menu_name = 'main-menu';
$locations = get_nav_menu_locations();
$menu = $locations ? wp_get_nav_menu_object( $locations[ $menu_name ] ) : null;
$menu_items = $menu ? wp_get_nav_menu_items( $menu->term_id, array( 'order' => 'DESC' ) ) : array();
$items = array();
$ID = get_the_ID();
$no = 0;
$main = '';
function isSubActive($childID, $ID) {
if (!$ID):
return false;
endif;
if ($childID == $ID):
return true;
endif;
return ( get_post_meta( $childID, 'page', true ) == "employees-contacts" && pods( 'division' )->find( array( 'limit' => 1, 'where'=>"page-id.ID = " . $ID ) )->total() ) ? true : false;
}
foreach( $menu_items as $menu_item ):
if ($menu_item->menu_item_parent == 0):
$no++;
$items[$menu_item->ID]['props'] = $menu_item;
$items[$menu_item->ID]['no'] = $no;
$items[$menu_item->ID]['active'] = ($menu_item->object_id == $ID) ? true : false;
else:
$items[$menu_item->menu_item_parent]['children'][] = $menu_item;
if ($menu_item->object_id == $ID):
$items[$menu_item->menu_item_parent]['active'] = true;
endif;
endif;
endforeach;
$main .= '<ul class="o-nav c-nav--main">';
foreach($items as $item) :
$children = array_key_exists('children', $item);
$url = ($children) ? $item['children'][0]->url : $item['props']->url;
$sectionCSS = ( get_post_meta( $post->ID, 'section', true) == get_post_meta( $item['props']->object_id, 'section', true )) ? 'is-nav--main-item-active' : '';
$main .= '<li class="c-nav--main-item ' . $sectionCSS . '">';
$classCSS = ($item['active']) ? 'is-nav--main-anchor-active' : '';
$main .= '<a href="' . $url . '" title="' . get_the_title($item['props']->object_id) . '" class="c-nav--main-anchor ' . $classCSS . '">' . $item['props']->title . '</a>';
if ( $children ) :
$main .= '<ul class="o-nav c-nav--sub">';
foreach($item['children'] as $child) :
$classCSS = isSubActive($child->object_id, $ID ) ? 'is-nav--sub-anchor-active' : '';
$main .= '<li class="c-nav--sub-item"><a href="' . $child->url . '" title="' . get_the_title($child->object_id) . '" class="c-nav--sub-anchor ' . $classCSS .'">' . $child->title . '</a></li>';
endforeach;
$main .= '</ul>';
endif;
$main .= '</li>';
endforeach;
$main .= '</ul>';
echo $main;
?>
<?php
// delog('', 'post');
// debug($post);
// delog($post->ID, 'post ID');
$menu_name = 'main-menu';
$locations = get_nav_menu_locations();
$menu = $locations ? wp_get_nav_menu_object( $locations[ $menu_name ] ) : null;
$menu_items = $menu ? wp_get_nav_menu_items( $menu->term_id, array( 'order' => 'DESC' ) ) : array();
$items = array();
$ID = get_the_ID();
$no = 0;
$main = '';
function isSubActive($childID, $ID) {
if (!$ID):
return false;
endif;
if ($childID == $ID):
return true;
endif;
return ( get_post_meta( $childID, 'page', true ) == "employees-contacts" && pods( 'division' )->find( array( 'limit' => 1, 'where'=>"page-id.ID = " . $ID ) )->total() ) ? true : false;
}
foreach( $menu_items as $menu_item ):
if ($menu_item->menu_item_parent == 0):
$no++;
$items[$menu_item->ID]['props'] = $menu_item;
$items[$menu_item->ID]['no'] = $no;
$items[$menu_item->ID]['active'] = ($menu_item->object_id == $ID) ? true : false;
else:
$items[$menu_item->menu_item_parent]['children'][] = $menu_item;
if ($menu_item->object_id == $ID):
$items[$menu_item->menu_item_parent]['active'] = true;
endif;
endif;
endforeach;
$main .= '<ul class="o-nav c-nav--main">';
foreach($items as $item) :
$children = array_key_exists('children', $item);
$url = ($children) ? $item['children'][0]->url : $item['props']->url;
$sectionCSS = ( get_post_meta( $post->ID, 'section', true) == get_post_meta( $item['props']->object_id, 'section', true )) ? 'is-nav--main-item-active' : '';
$main .= '<li class="c-nav--main-item ' . $sectionCSS . '">';
$classCSS = ($item['active']) ? 'is-nav--main-anchor-active' : '';
$main .= '<a href="' . $url . '" title="' . get_the_title($item['props']->object_id) . '" class="c-nav--main-anchor ' . $classCSS . '">' . $item['props']->title . '</a>';
if ( $children ) :
$main .= '<ul class="o-nav c-nav--sub">';
foreach($item['children'] as $child) :
$classCSS = isSubActive($child->object_id, $ID ) ? 'is-nav--sub-anchor-active' : '';
$main .= '<li class="c-nav--sub-item"><a href="' . $child->url . '" title="' . get_the_title($child->object_id) . '" class="c-nav--sub-anchor ' . $classCSS .'">' . $child->title . '</a></li>';
endforeach;
$main .= '</ul>';
endif;
$main .= '</li>';
endforeach;
$main .= '</ul>';
echo $main;
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment