Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8066887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:07:45+00:00 2026-06-05T12:07:45+00:00

I need to add HTML to the Category names within my WordPress theme, so

  • 0

I need to add HTML to the Category names within my WordPress theme, so that I can define the name as an icon (via the Twitter bootstrap).

Example code as follows:

<a href="link">
<i class="icon-briefcase"></i>
</a>

This would present the Category name as a linked icon.

Is there any way to do this. I’ve searched endlessly and the only WordPress plugins I can find allow HTML to be added to the Category description only.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T12:07:47+00:00Added an answer on June 5, 2026 at 12:07 pm

    I think what you’re trying to do you can easily solve like this:

    <?php 
    foreach((get_the_category()) as $category) { 
        echo '<a href="link">';
        echo '<i class="icon-briefcase">' . $category->cat_name . '</i>';
        echo '</a>'; 
    } 
    ?>
    

    This will make all the category names appear like linked icons, like you said. If you want each name to have a different icon you can of course add a conditional statement to render different HTML based on the category name or ID.

    EDIT:

    Because you want to use the Twitter Bootstrap, you need to assign css classes to the links in order to the display the icon. There are two ways you can do this. One of ’em being that you could name your categories the same as the icons. For example, a category named ‘briefcase’, would render a link with the class ‘icon-briefcase’. The code:

    <?php 
        // Iterate through the available categories
        foreach((get_the_category()) as $category) { 
            echo '<a href="link">'; // Display a link
            echo '<i class="icon-' . $category->cat_name . '">' . $category->cat_name . '</i>'; // Create the <li>
            echo '</a>';
        } 
        ?>
    

    The second way, and I think a bit better for content purposes (more freedom for choice of cat names), would be to use a conditional statement in the code to assign icons to certain categories. For example:

    <?php 
            // Iterate through the available categories
            foreach((get_the_category()) as $category) {
                // First define a default css name class to use
                $iconclass = 'icon-default';
                // Then using an if statement, assign a new css class name to the variable based on the name of the category
                if($category->cat_name == 'Travel') { $iconclass = 'icon-briefcase'; } 
    
                echo '<a href="link">'; // Display a link
                echo '<i class="'. $iconclass . '">' . $category->cat_name . '</i>'; // Create the <li>
                echo '</a>';
            } 
            ?>
    

    I hope this is clear enough.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Within a for loop, i need to add some HTML that outputs only when
I need to add links to WordPress Posts on a static HTML page. I
I need to add two lines of html to every page on a large
I need to add annotations to existing HTML documents - best in the form
After inserting new html to DOM,I need to add some listeners to it. But
I'm working on a wordpress theme that uses dropdowns for part of the site
I have a need to add custom HTML attributes, specifically classes or styles to
I need to add data to a field that already contains data without erasing
I need to add some html right after the body tag so like :
I need to add a HTML style container in the section of a particular

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.