marko krstić

Collections

Archives

List categories and taxonomies with class active

List of categories for posts with link to archive and wrapped in classes

<ul>
    <?php wp_list_categories( array(
        'orderby'    => 'name',        
  		'title_li' => '',
        'hide_title_if_empty' => true,
    ) ); ?> 
</ul>

To enable it for taxonomies add this line and replace 'produckte' with your taxonomy slug

'taxonomy'  => 'produkte',

And on the end you will get this for custom categories ( taxonomies)

<ul>
    <?php wp_list_categories( array(
		'taxonomy'  => 'produkte',
        'orderby'    => 'name',        
  		'title_li' => '',
        'hide_title_if_empty' => true,
    ) ); ?> 
</ul>

Here is preview of HTML output:

<ul>
	<li class="cat-item cat-item-1 current-cat">
		<a aria-current="page" href="link">Cat name 1</a>
	</li>

	<li class="cat-item cat-item-2">
		<a aria-current="page" href="link">Cat name 2</a>
	</li>

	<li class="cat-item cat-item-3">
		<a aria-current="page" href="link">Cat name 3</a>
	</li>
</ul>

Let's Connect

Feel free to reach out for collaborations or just a friendly hello ?
[email protected]
linkedininstagramdribbblefacebook-official