I've been working with the wp_list_categories( $args );
to display categories from a taxonomy and I feel that this might be the wrong method to use. Now I'm wondering if it is possible to instead of having the categories outputted into an unordered list, they are outputted as individual div elements for each category. Is there a better alternative to doing this?
<?php
$args = array(
'show_option_none' => __( 'No treatment categories' ),
'taxonomy' => 'treatment-categories',
'title_li' => __( 'Treatment Categories' )
);
wp_list_categories( $args );
?>
My original prototype of the site is using a grid system with individual columns for each category.
I have worked with get_categories( $args );
and I was able to accommplish what was expected, however I had an issue of trying to link to each category when a user would click on the 'View Treatment' button, it would take the user to the 404 page. Here was the template I was building when I was working with get_categories( $args );
.
<?php get_header(); ?>
<section class="hero hero-sml hero-default no-marg-bottom">
<div class="container clearfix">
<h1>Treatments</h1>
</div><!-- .container -->
</section><!-- .hero -->
<section class="margin-top container clearfix">
<div class="row">
<?php
$args = array(
'taxonomy' => 'treatment-categories',
);
$categories = get_categories( $args );
foreach( $categories as $category ) {
?>
<div class="col-4 treatment-category">
<h3>
<?php echo $category->name; ?>
</h3>
<p>
<?php echo $category->description; ?>
</p>
<p>
<a class="btn btn-sml btn-clr btn-primary" href="<?php echo esc_url( $category_link ); ?>">
View treatments
</a>
</p>
</div><!-- .col-4 -->
<?php
}
?>
</div><!-- .row -->
</section><!-- .container -->
<?php get_footer(); ?>
Any help on how I can achieve this will be greatly appreciated as I've been stuck on this for a couple of weeks.