Haal de bovenste parent categorie op en laat de children zien op elke sub pagina (of sub-sub pagina).

<?php 
			$product_parent_categories_all_hierachy = get_ancestors( $post->ID, 'page' );  
			$last_parent_cat = array_slice($product_parent_categories_all_hierachy, -1, 1, true);				
			if ( is_page() && $post->post_parent ):
			 	if($last_parent_cat[1]){
					$childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $last_parent_cat[1] . '&echo=0&depth=1' );
				} else {
					$childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $last_parent_cat[0] . '&echo=0&depth=1' );
				};
			else:
				$childpages = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0&depth=1' );
			endif;
			?>

 

Geef een reactie 0