• Resolved mireillesan

    (@mireillesan)


    I’d like to add a span tag to display categories.

    How it is right now:
    <li class="cat-item cat-item-7"><a href="#">category #1</a></li>

    How I’d like it to be:
    <li class="cat-item cat-item-7"><a href="#"><span>category #1</span></a></li>

    Unlike the other threads I’ve read, I’d like to do this inside my function.php file through a filter.

Viewing 4 replies - 1 through 4 (of 4 total)
  • This can the workaround for you..

    <?php
    $categories = get_categories();
    $html = '<ul>';
    foreach ( $categories as $category ) {
    	$cat_link =  get_category_link( $category->term_id );
    
    	$html .= "<li class='{$category->slug}'><a href='{$cat_link}'>";
    	$html .= "<span>{$category->name}</span></a></li>";
    }
    $html .= '</ul>';
    echo $html;
     ?>
    Thread Starter mireillesan

    (@mireillesan)

    Sadly, that doesn’t work with my theme.

    BTW what us your theme name ?

    Thread Starter mireillesan

    (@mireillesan)

    I use a premiumpress theme.

    Luckily enough I happened to stumble on the solution I found inside a German forum hidden deep inside google search results.

    Thank you and I greatly appreciate your willingness to help me.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Add span to wp_list_categories’ is closed to new replies.