function wos_media_categories($args) { $pc = getParentCat(); //echo $pc; $cat_test = get_post($_GET['attachment_id'])->post_category; //$categories = get_categories('hide_empty=0'); // Get all available Categories $categories = get_categories('child_of=' . $pc . '&hide_empty=0'); // Get all available Categories $post_categories = wp_get_post_categories($_GET['attachment_id']); // Get this posts' Categories $all_cats .= '<ul id="wos-media-categories-list" style="width:500px;">'; foreach ($categories as $category) { if (in_array($category->term_id, $post_categories)) { $chk = ' checked="checked"'; } else { $chk = ''; } $option = '<li style="width:240px;float:left;"><input type="checkbox" onclick="wos_category_click(this)" class="wos-categories-cb" value="' . $category->category_nicename . '" id="' . $category->category_nicename . '" name="' . $category->category_nicename . '"' . $chk . '> '; $option .= '<label for="' . $category->category_nicename . '">' . $category->cat_name . '</label>'; $option .= '</li>'; $all_cats .= $option; } $all_cats .= '</ul>'; // Format Category fields on page $categories = array('all_categories' => array('label' => __('Category'), 'input' => 'html', 'html' => $all_cats)); return array_merge($args, $categories); }
<div class="postBread"> <ul class="breadList"> <?php if (is_category()) { $cat = get_query_var('cat'); $yourcat = get_category($cat); } $globalCatType = ""; $idObj = get_category_by_slug($yourcat->slug); $parentCat = getParentCat($idObj->cat_ID, $wpdb); if (is_array($parentCat) && count($parentCat) >= 1) { $parentCat = rearrangeCategory($parentCat, $arrCatAll); global $parentCat; $prevCat = ""; $selectedCat = ""; foreach ($parentCat as $category) { if (in_array($category->name, $arrCatIsland)) { $currentIsland = $category->name . ", Philippines"; } $prevCat = $prevCat . $category->slug . "/"; ?> <li><a href="<?php echo $category_base . "/" . $prevCat; ?> "><?php echo $category->name; ?> </a></li> <?php }