Hello,
you should be able to do this in the Template Editor: in your backend go to Theme -> Customizer, then go to Templates and select “Single” here you can make the post title on single post pages italic.
You’ll need to add custom CSS in APPEARANCE => CUSTOMIZE => ADDITIONAL CSS.
If you can provide your website address, I can check your site and give you the custom CSS code that’s 100% guaranteed to work.
Dear George
Thank you for your offer!
The problem is that I only want to display individual parts of the title in Italic. The whole title would not be a problem. But I just can’t put extra tags in the title.
The problem is that I only want to display individual parts of the title in Italic.
In that case, the CSS approach wouldn’t be a viable solution.
That said, I can add the <i> and <em> HTML tags in a test site I just put up, and the tags are not removed upon publishing/updating the post. So I’m not sure what’s going on on your website.
It seems your theme or one of your plugins is stripping HTML tags out of titles. I tested similar to George’s with 2021 theme and no plugins and I can use em tags in titles with no issues. Isolate which module is stripping tags. Switch to one of the Twenty* default themes and deactivate all plugins. You should be able to save titles with HTML tags now. Restore your normal theme, then plugins, one at a time, making test saves after each. When tags get stripped again, the last activated is the cause.
You could follow up through that module’s dedicated support channel to see if there’s a way to disable this “feature”.
hmmm, I am using a theme I have build from scratch on my own. But I’ve done this only twice, while googling most of the requested stuff…
Is there something (a line of code …?) I can add to the theme to get back the ability for using <em> in the title? 🤔
If you built the theme, I’d think you’d know if you did something to strip HTML tags out of titles. That is, unless you’ve imported code from elsewhere without fully understanding what it does. No judgement here, it’s what some people do. Otherwise it’s likely due to one of your plugins.
Either way, you’d need to find where the tag removal is being done. If you can find it, there’s a chance you’d be able cleanly override the removal. Of course, if found, you could simply remove the offending code. Editing source code is not the best option because you’d need to redo the same edit after every update. Ideally there’d be some sort of filter callback or something where you could use remove_filter() without editing the original source code.
Finding where the removal is done can be a challenge. Narrow down where to look like I descried earlier. If you’re lucky, removal is done with something obvious like wp_strip_all_tags(). But removal could be accomplished any number of ways, preg_replace() for example.