1

this function produce this html

<ul class="post-categories"> <li><a href="#" rel="category tag" class="text">test</a></li> <li><a href="#" rel="category tag" class="text">test</a></li> </ul> 

but i need this html

<ul class="post-categories"> <li> <a href="#" rel="category tag" class="text"> <span class="hover-toggle">Farm to Cup</span> <span class="hover-toggle">Farm to Cup</span> </a> </li> <li> <a href="#" rel="category tag" class="text"> <span class="hover-toggle">Farm to Cup</span> <span class="hover-toggle">Farm to Cup</span> </a> </li> 

i s there any solution?

1 Answer 1

1

you could use this snippet, and modify the output string accordingly.

$categories = get_the_category(); $separator = ' '; $output = ''; if ( ! empty( $categories ) ) { foreach( $categories as $category ) { $output .= '<a href="' . esc_url( get_category_link( $category->term_id ) ) . '" alt="' . esc_attr( sprintf( __( 'View all posts in %s', 'textdomain' ), $category->name ) ) . '">' . esc_html( $category->name ) . '</a>' . $separator; } echo trim( $output, $separator ); } 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.