I'm trying to do drop caps in the Twenty Twenty-Three theme on WordPress 6.2.2.
All the docs I find when I google it are for older versions of WordPress, and possibly on an older theme. It used to be easy, but I can't find relevant docs for how to do this with the Twenty Twenty-Three theme.
And following on from that, how do I add custom CSS to use a different font for the drop caps?
I have a couple of older posts from an earlier version of WP that have drop caps and I used to have them styled via a child theme I was using, but I upgraded to the Twenty Twenty Three theme and I lost all my customisations.
I've added the following code via the "Tools > Theme file editor", but it doesn't seem to be working.
p.has-drop-cap:not(:focus)::first-letter
{
font-family: 'Fredericka the Great', cursive;
}
Neither TwentyTwentyTwo nor TwentyTwentyThree currently support
dropCaps. Since the layout looks undesirable on certain user systems, it was agreed that dropcap support is not mandatory for either theme. Read more - WordPress issues: https://github.com/WordPress/twentytwentytwo/issues/180But there's a workaround available. Since you have to touch the theme core files, the use of a child theme is probably not a bad idea. Otherwise, adjustments could be overwritten when updating.
The workaround was first pointed out in a comment by @colorful-tones a user on GitHub, in this thread. The related CSS is from @justintadlock, another GitHub user, you can read more here.
So here are the steps you need to take to enable
dropCapsupport:theme.json.typography, change the value fordropCapfromfalsetotrue.style.cssand add:NOTE: If you want to use a custom font you may have to add your font to the typography section in
theme.json. A support topic from WordPress.org could be helpful hereby. You can also try to replace all variables directly in the CSS part with your own values. But I'm sorry I can't remember if it worked like that, because I used this workaround only once and it was some time ago and the page doesn't exist like that anymore. You'll just have to test it yourself.Finally, don't forget to properly include your Fredericka the Great font into Wordpress.
Hope this works for you.