wordpress - Get top-level category and make it a link -
wordpress - trying top-level parent category name , make link
categories structured
europe > eastern europe > poland
in instance wan cat name europe , make link cat page europe.
no matter try not seem able top category. being executed in custom qp query
here go
get top level categories
<?php $args = array( 'orderby' => 'name', 'parent' => 0 ); $categories = get_categories( $args ); foreach ( $categories $category ) { echo '<a href="' . get_category_link( $category->term_id ) . '">' . $category->name . '</a><br/>'; } ?>
get top level categories / taxonomy
<?php $args = array( 'type' => 'post', 'orderby' => 'term_group', 'hide_empty' => 0, 'hierarchical' => 0, 'parent' => 0, 'taxonomy' => '..if using taxonomy instead of category' ); get_categories( $args ); ?>
Comments
Post a Comment