I’ve been trying for hours to display a sub taxonomy and I’m almost there
I have the titles displaying but I want the sub taxonomy description showing aswell,
this is in WordPress
<?php
//first get the current term
$current_term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
//then set the args for wp_list_categories
$args = array(
'child_of' => $current_term->term_id,
'taxonomy' => $current_term->taxonomy,
'hide_empty' => 0,
'hierarchical' => true,
'depth' => 1,
'title_li' => '',
);
?>
<?php foreach ( $args as $arg ) { ?>
<div class="col-md-6">
<article>
<header class="entry-header">
<h2><?php wp_list_categories( $args ); ?></h2>
</header>
</article>
</div>
<?php } ?>
I’ve tried to add a for each as well which didn’t work XD
please is anyone could help it would be awesome
<?php
$cat_args = array(
'taxonomy' => 'business_categories',
'orderby' => 'name',
'order' => 'ASC',
'number'=> 2,
);
$categories = get_categories( $cat_args );
foreach ( $categories as $category ) {
?>
<div class="col-md-6">
<h3>
<a href="<?= get_category_link( $category->term_id ) ?>"><?= $category->name ?></a>
</h3>
<p>
<a href="<?= get_category_link( $category->term_id ) ?>"><?= $category->category_description ?></a>
</p>
</div>
<!-- <pre>
<?php print_r( $categories ); ?>
</pre> -->
<?php } ?>
this is how I’m displaying my taxonomy
2
Answers
I got the answer
the get get_category_link only displays the HTML title output
hopefully, this will help anyone in a similar situation
Try somthing like this