Reputation: 23
I need to have the word "Located:" in bold but can't figure out where to put the tags so they don't either print or break the code.
Read other threads here, put the bold tags around Located: but they just print. Tried moving the tags but it breaks the code.
/* translators: used between list items, there is a space after the comma
*/
$tags_list = get_the_tag_list( '', esc_html__( ', ', 'vogue' ) );
if ( $tags_list ) {
printf( '<br /><br /><span class="tags-links">' . esc_html__( '<b>Located:</b> %1$s', 'vogue' ) . '</span>', $tags_list ); // WPCS: XSS OK
}
Upvotes: 2
Views: 1568
Reputation: 42710
esc_html
will escape any HTML you give it, so don't put the HTML in. Simple enough! You're using esc_html__
and not just esc_html
so I assume localization is important to you.
$tags_list = get_the_tag_list( '', esc_html__( ', ', 'vogue' ) );
if ( $tags_list ) {
printf(
'<br /><br /><span class="tags-links"><b>%s</b>%s</span>',
__( 'Located:', 'vogue' ),
$tags_list
);
}
printf
will replace each %s
with a string representation of the argument, so all I've done is moved the translation of "Located:" into a separate argument. I'm not sure what you were going for with %1$s
so I took it out and replaced it with a standard %s
.
Upvotes: 2
Reputation: 457
if ($tags_list ) {
printf(
'<br /><br /><span class="tags-links"><b>Located:</b> ' . esc_html__('%1$s', 'vogue' ) . '</span>',
$tags_list
); // WPCS: XSS OK
}
Upvotes: 0