Skip to main content
added 10 characters in body
Source Link

toIn the above 'answer', the last line which prints the category name is not actually doing so.

It should look like this:

$categories = get_the_category();
foreach( $categories as $category) {
    $name = $category->name;
    $category_link = get_category_link( $category->term_id );

    echo "<a href='$category_link'>
            <span class=" . esc_attr( $name) . ">" . esc_attr( $name) . "</span>
         </a>";
}

to the above 'answer' the last line which prints the category name is not doing so.

It should look like this:

$categories = get_the_category();
foreach( $categories as $category) {
    $name = $category->name;
    $category_link = get_category_link( $category->term_id );

    echo "<a href='$category_link'>
            <span class=" . esc_attr( $name) . ">" . esc_attr( $name) . "</span>
         </a>";
}

In the above 'answer', the last line which prints the category name is not actually doing so.

It should look like this:

$categories = get_the_category();
foreach( $categories as $category) {
    $name = $category->name;
    $category_link = get_category_link( $category->term_id );

    echo "<a href='$category_link'>
            <span class=" . esc_attr( $name) . ">" . esc_attr( $name) . "</span>
         </a>";
}
Source Link

to the above 'answer' the last line which prints the category name is not doing so.

It should look like this:

$categories = get_the_category();
foreach( $categories as $category) {
    $name = $category->name;
    $category_link = get_category_link( $category->term_id );

    echo "<a href='$category_link'>
            <span class=" . esc_attr( $name) . ">" . esc_attr( $name) . "</span>
         </a>";
}