In which I explain how to create dropcaps

WordPress Mod:  DropCaps

The chances of me ever using the WordPress str QuickTag are pretty slim, so I replaced it with a drop-capper. (The T in this paragraph should appear as a dropcap for you if you’re using a browser that handles CSS properly.)

Pretty nifty, I think.

Want to do it?


NOTE: As of WordPress 2.04 the quicktags.js file has been moved to wp-includes/js/ and is no longer located in wp-admin!

Open the file wp-admin/quicktags.js and look for the lines that add the str quicktag. They look like this:

edButtons[edButtons.length] = 
new edButton('ed_strong'
,'str'
,'<str>'
,'</str>'
,'b'
);

Change them to this:

edButtons[edButtons.length] = 
new edButton('ed_dropcap'
,'DropCap'
,'<span class="dropcap">'
,'</span>'
,'b'
);

Then add this class to your stylesheet:

.dropcap{
	float: left;
	font: bold 250%/normal Verdana, Arial, sans-serif;
	margin-bottom: -5px;
}

I was going to create this as a my first real plug-in, but the the_content() function echos and doesn’t actually return an editable variable, so it got all tricky and I said screw it. If anyone knows of a way to get the_content() to return a variable, let me know and I’ll convert this to a plug-in. I’m afraid I am not quite yet a master of PHP, and I didn’t want to start screwing around with the core WP files that control the output of the_content(), so …

Post the first comment:

I'll never share your email address and it won't be published.

What Is This?

davidgagne.net is the personal weblog of me, David Vincent Gagne. I've been publishing here since 1999, which makes this one of the oldest continuously-updated websites on the Internet.

bartender.live

A few years ago I was trying to determine what cocktails I could make with the alcohol I had at home. I searched the App Store but couldn't find an app that would let me do that, so I built one.

Hemingway

You can read dozens of essays and articles and find hundreds of links to other sites with stories and information about Ernest Hemingway in The Hemingway Collection.