Commit 3cc536ac authored by Simon's avatar Simon

Job categories fix

parent 4a371dc6
...@@ -125,19 +125,23 @@ get_header(); ...@@ -125,19 +125,23 @@ get_header();
$occupationalCategories = get_the_terms( $ID, 'field' ); $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 ; ?>" /> <meta itemprop="occupationalCategory" content="<?php echo $occupationalCategory->name ; ?>" />
<?php <?php
endforeach; endforeach;
endif;
$employmentTypes = get_the_terms( $ID, 'type' ); $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; ?>" /> <meta itemprop="employmentType" content="<?php echo $employmentType->name; ?>" />
<?php <?php
endforeach; endforeach;
endif;
?> ?>
<ul class="c-categories"> <ul class="c-categories">
<?php <?php
......
<?php <?php
// delog('', 'post'); // delog('', 'post');
// debug($post); // debug($post);
// delog($post->ID, 'post ID'); // delog($post->ID, 'post ID');
$menu_name = 'main-menu'; $menu_name = 'main-menu';
$locations = get_nav_menu_locations(); $locations = get_nav_menu_locations();
$menu = $locations ? wp_get_nav_menu_object( $locations[ $menu_name ] ) : null; $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(); $menu_items = $menu ? wp_get_nav_menu_items( $menu->term_id, array( 'order' => 'DESC' ) ) : array();
$items = array(); $items = array();
$ID = get_the_ID(); $ID = get_the_ID();
$no = 0; $no = 0;
$main = ''; $main = '';
function isSubActive($childID, $ID) { function isSubActive($childID, $ID) {
if (!$ID): if (!$ID):
return false; return false;
endif; endif;
if ($childID == $ID): if ($childID == $ID):
return true; return true;
endif; endif;
return ( get_post_meta( $childID, 'page', true ) == "employees-contacts" && pods( 'division' )->find( array( 'limit' => 1, 'where'=>"page-id.ID = " . $ID ) )->total() ) ? true : false; 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 ): foreach( $menu_items as $menu_item ):
if ($menu_item->menu_item_parent == 0): if ($menu_item->menu_item_parent == 0):
$no++; $no++;
$items[$menu_item->ID]['props'] = $menu_item; $items[$menu_item->ID]['props'] = $menu_item;
$items[$menu_item->ID]['no'] = $no; $items[$menu_item->ID]['no'] = $no;
$items[$menu_item->ID]['active'] = ($menu_item->object_id == $ID) ? true : false; $items[$menu_item->ID]['active'] = ($menu_item->object_id == $ID) ? true : false;
else: else:
$items[$menu_item->menu_item_parent]['children'][] = $menu_item; $items[$menu_item->menu_item_parent]['children'][] = $menu_item;
if ($menu_item->object_id == $ID): if ($menu_item->object_id == $ID):
$items[$menu_item->menu_item_parent]['active'] = true; $items[$menu_item->menu_item_parent]['active'] = true;
endif; endif;
endif; endif;
endforeach; endforeach;
$main .= '<ul class="o-nav c-nav--main">'; $main .= '<ul class="o-nav c-nav--main">';
foreach($items as $item) : foreach($items as $item) :
$children = array_key_exists('children', $item); $children = array_key_exists('children', $item);
$url = ($children) ? $item['children'][0]->url : $item['props']->url; $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' : ''; $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 . '">'; $main .= '<li class="c-nav--main-item ' . $sectionCSS . '">';
$classCSS = ($item['active']) ? 'is-nav--main-anchor-active' : ''; $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>'; $main .= '<a href="' . $url . '" title="' . get_the_title($item['props']->object_id) . '" class="c-nav--main-anchor ' . $classCSS . '">' . $item['props']->title . '</a>';
if ( $children ) : if ( $children ) :
$main .= '<ul class="o-nav c-nav--sub">'; $main .= '<ul class="o-nav c-nav--sub">';
foreach($item['children'] as $child) : foreach($item['children'] as $child) :
$classCSS = isSubActive($child->object_id, $ID ) ? 'is-nav--sub-anchor-active' : ''; $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>'; $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; endforeach;
$main .= '</ul>'; $main .= '</ul>';
endif; endif;
$main .= '</li>'; $main .= '</li>';
endforeach; endforeach;
$main .= '</ul>'; $main .= '</ul>';
echo $main; 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