0

I'd like to be able to use

<b></b>

within my Category Title in Wordpress but the admin strips them out.

I realise I can make the whole title bold using css but I only want it to apply to certain words.

Is there a way of enabling this?

Thanks for any help in advance.

  • How and in what part of the theme are categories being displayed? – brasofilo Nov 1 '13 at 14:20
2

I am not sure if you can force the system to accept markup in the category titles, and I am not sure you should even try so I am going to suggest that you hack together a kind of markdown. Use some character like * as a placeholder then...

add_filter(
  'the_category',
  function($categories) {
    $pattern = '|(\*)([^\*]+)(\*)|';
    return preg_replace($pattern,'<b>$2</b>',$categories);
  }
);

I am not sure how robust that is. I am sure the callback could be much better but it works when I test it.

Also, a lot depends on how you are displaying the categories. I am not even sure if that is the filter you need. Your questions does not provide that information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.