<?php
function get_cat_hierchy($parent,$args){
$cats = get_categories($args);
$ret = new stdClass;
foreach($cats as $cat){
if($cat->parent==$parent){
$id = $cat->cat_ID;
$ret->$id = $cat;
$ret->$id->children = get_cat_hierchy($id,$args);
}
}
return $ret;
}
$args = array(
'type' => 'post',
'child_of' => 0,
'hide_empty' => false,
'hierarchical' => true,
'exclude' => '1'
);
$parent=0;
// Display_cat_under_posts(0,$args);
//function Display_cat_under_posts($parent,$args){
$retarray=get_cat_hierchy($parent,$args);
//echo ($retarray->name);
foreach($retarray as $airport) {
echo "<h1>".$airport->name."</h1><br>";
foreach($airport->children as $airport2)
{
echo "<h2> <a href='?cat=".$airport2->term_id."'>".$airport2->name."</a></h2><br>";
query_posts( 'cat='.$airport2->term_id );
while ( have_posts() ) : the_post();
?>
<li><a href='<?php the_permalink() ?>'
rel='bookmark' title='<?php the_title(); ?>'>
<?php the_title(); ?></a></li>
<?php
endwhile;
wp_reset_query();
echo "<p>-------------------------------------------------------------------<p>";
}
}
//}
////////////////////
/*
stdClass Object (
[3] => stdClass Object (
[term_id] => 3
[name] => IT
[slug] => it
[term_group] => 0
[term_taxonomy_id] => 3
[taxonomy] => category
[description] => [parent] => 0 [count] => 1 [cat_ID] => 3
[category_count] => 1
[category_description] => [cat_name] => IT [category_nicename] => it [category_parent] => 0
[children] => stdClass Object ( [4] => stdClass Object ( [term_id] => 4 [name] => android [slug] => android [term_group] => 0 [term_taxonomy_id] => 4 [taxonomy] => category [description] => [parent] => 3 [count] => 1 [cat_ID] => 4 [category_count] => 1 [category_description] => [cat_name] => android [category_nicename] => android [category_parent] => 3 [children] => stdClass Object ( ) ) [5] => stdClass Object ( [term_id] => 5 [name] => iOS [slug] => ios [term_group] => 0 [term_taxonomy_id] => 5 [taxonomy] => category [description] => [parent] => 3 [count] => 1 [cat_ID] => 5 [category_count] => 1 [category_description] => [cat_name] => iOS [category_nicename] => ios [category_parent] => 3 [children] => stdClass Object ( ) ) ) ) )
*/
echo "<p><p><p><p>";
?>
<div class='breadcrumb'>
<?php // if there is a parent, display the link
$parent_title = get_the_title($post->post_parent);
if ( $parent_title != the_title(' ', ' ', false) ) {
echo '<a href=' . get_permalink($post->post_parent)
. ' ' . 'title=' . $parent_title . '>' . $parent_title
. '</a> » ';
}
// then go on to the current page link
?>
<a href='<?php the_permalink() ?>'
rel='bookmark' title='<?php the_title(); ?>'>
<?php the_title(); ?></a>
</div>
Post navigation