DropCap First Character WordPress Plugin
by Rodney Campbell on Jul.27, 2006, under Technology
OK – I've written my first WordPress plugin – it is incredibly simple and VERY short but it does the job none-the-less. The plugin is called dropcap_first and is available for download if you so desire.
What it does is it makes the first character of the post BIG in a magazine style. I got the idea (and most of the CSS code) to do this from an article called Magazine Style CSS Drop Caps and then it was just a matter of writing the relevant PHP code to do what I wanted.
Current Version Download: dropcap_first plugin
Installation:
- download the latest version the plugin (above).
- upload the entire plugin folder to your wordpress plugins folder (wp-content/plugins) on your server.
- activate the DropCap First Character plugin in WordPress Plugins administration tab.
The plugin consists of two files. The PHP file (dropcap_first.php) which does the work (the important code is below):
function dropcap_header() {
echo('<link rel="stylesheet" type="text/css" media="screen" xhref="' . get_bloginfo('wpurl') . '/wp-content/plugins/dropcap_first/dropcap_style.css" />');
}
add_action('wp_head', 'dropcap_header');
function dropcap_first($content='') {
$pos = stripos($content, '<p>');
if (($pos !== 0) || ($pos === false)) {
return '<p class="dropcap-first">' . $content;
} else {
return '<p class="dropcap-first"' . stristr($content, '>');
}
}
add_filter('the_content', 'dropcap_first', 7);
and a stylesheet file (dropcap_style.css) which defines what the character will look like and uses the :first-letter pseudo element to limit the effect to the first character of the post.
p.dropcap-first:first-letter {
color: #D4D4C7;
float: left;
font-size:80px;
line-height:60px;
padding-top:4px;
padding-right:5px;
font-family: Times, serif, Georgia;
}
If you wanted to change what the first character looked like (the colour, size, font, etc) then you just need to adjust this stylesheet entry. If you like the look of this you can add it to your own WordPress blog by downloading the dropcap_first plugin and installing it as per usual – this plugin requires no other manual edits to work.
November 30th, -0001 on 12:00 am
Скачать беплано дипломную5по дPсциплине http//www.myllionreceptov.ru/category_124.html – Финансы предприятий
Республика Молдова
Коллекция рефератов
July 28th, 2006 on 12:02 am
cool idea but iget this error:
—
Fatal error: Call to undefined function: stripos() in /home/mcclain/public_html/wp/wp-content/plugins/dropcap_first/dropcap_first.php on line 34
—
any idea? thanks…
July 28th, 2006 on 3:33 am
change it with “strpos” 🙂
July 28th, 2006 on 3:36 am
Live example here: http://www.virgolamobile.net
July 28th, 2006 on 6:39 pm
Thanks Niccolo
Since stripos is only available in fairly new PHP versions I’ve changed it to use strpos(which is more widely available) and we’ll live with using the case sensitive version so it won’t match <P>.
July 28th, 2006 on 11:59 pm
thanks that fixed it!
September 10th, 2006 on 8:53 am
Is it possible to have the plugin deactivated only for a specific page or post? I used it together with the KG Archives plugin, where a page is populated automatically with all post titles, and the page came empty
September 10th, 2006 on 8:54 am
Is it possible to have the plugin deactivated only for a specific page or post? I used it together with the KG Archives plugin, where a page is populated automatically with all post titles.
October 13th, 2006 on 7:54 pm
Just found this plugin from wp-plugins trying to create this effect. It looks fine, but it doesn’t hav a drop-shadow.
Any plans to include this effect in the future? Been tinkering with the stylesheet but no dice. 🙁
October 21st, 2006 on 11:55 pm
Excellent pluggie Rodney. I thought sthg was wrong at first as I wasn’t getting the effect.
Then I realised that if, like many of my posts, you have an image at the very beginning of the post, it won’t work.
That’s actually really elegant behaviour. Otherwise a pic big text would look kind of messy.
Ta again
Paul
October 24th, 2006 on 4:45 pm
Very nice plugin. You can see it in action at http://www.sbe38.org. It works perfectly for normal post, but not rss feeds. How can I modify to account for a post being an rss feed?
Also if I want to exclude a page from drop caps how can I acheive this?
thanks.
don (el paso)
November 24th, 2006 on 2:19 pm
I downloaded it and installs fine, but it only makes the dropcap on pages, not posts.
Example is here: The “W”elcome dropcap post is my own css.
You can see the plugin example on the about page.
http://www.Wahm-Blog.com
I didn’t change anything, so how do I get it to show up on posts, too, and not just pages?
Thanks!
November 29th, 2006 on 6:33 am
Great plug in, thanks for putting time and effort into it!!
December 5th, 2006 on 9:19 pm
Nice plugin, thanks! Looks fantastic on mine.
December 8th, 2006 on 1:16 am
it looks very nice, but almost all of my posts start with a thumbnail, so this plugin does nothing for me…
can it somehow detect html tags and skip over those?
December 12th, 2006 on 3:54 am
Great plugin! Thanks;
In action at http://www.adrianherritt.com
December 13th, 2006 on 6:59 am
What I want to do on my blog, is every few hours take the oldest post and move it to the
front of the queue, all automatically. Anyone know if there is a plugin that can do this or
a simple way to set up another plugin to do this (use my own feed perhaps)?
Thanks.
December 24th, 2006 on 3:49 pm
The drop caps are only appearing on one of the pages and not the posts. How do I fix this?
http://www.sharonvaz.com
January 3rd, 2007 on 3:28 am
Hi Rodney,
I’m using your DropCap on my website and it works great, but I have one problem. When I choose to “block justify” the post, the DropCap disappears. The only way to get it to work is to have the post “left justified”.
Any suggestions to get DropCap to work when its block justified?
Thanks,
– Mac
http://www.TheAviationNation.com
February 18th, 2007 on 7:40 am
Love it, clean and simple.
Thanks!!
http://www.RBHmultimedia.com/blog
March 5th, 2007 on 2:10 pm
Link is not working to download – just takes me to a different page
March 7th, 2007 on 8:17 am
Ooops – Sorry – my bad – it should be fixed now 🙂
April 24th, 2007 on 9:06 am
This plugin is great! But I want to take it a step further. If you study old style typography, when a drop cap is used, the subsequent paragraphs are indented. I tried to work this out myself, but I am afraid, I am not a programmer, just a humble graphic designer. Anyone have any ideas?
May 19th, 2007 on 2:27 am
Daniel, I bet you could set the left-margin of the dropcap to a negative number to give the effect of indenting the following paragraphs.
May 30th, 2007 on 8:27 am
You got some spam in your trackbacks.
Great plugin, by the way.
June 21st, 2007 on 7:14 am
Hi, the link to the plugin doesn’t work
July 26th, 2007 on 9:44 pm
Installed your plug-in and it looked great but it only shows the first letter of the first word as a drop cap but the rest of the word shows at the end of the post title instead of following the drop cap.
I had to uninstall it.
August 16th, 2007 on 3:10 am
Lovely and perfect, specially that it work only when theres no picture at the beggining of a post and that is perfect. Thanks a lot for this great plugin.
August 31st, 2007 on 8:06 am
i LOVE this plugin. my blog has excerpts on the front page, is there any way to get it to work on the excerpts too?
September 2nd, 2007 on 2:47 am
On my site doesn’t work…
Why not?
September 3rd, 2007 on 2:59 am
Great plug-in, relatively easy to customize.
It works fine in Firefox and Safari, on both the Mac and Windows, but in Internet Explorer, the drop-cap is elevated. Is there a CSS thing I could do to compensate for this?
Peace,
Gene
September 6th, 2007 on 1:00 pm
When I edit the beginning sentence of my posts, I seem to lose the drop cap. On two of my posts that were edited, the drop cap does not appear. It shows up on other posts. I deactivated and reactivated the plugin, and still have the same issue. I could recreate the posts, but would rather not go there.
Is there a way for me to restore the missing drop caps?
I ADORE this plugin, Rodney! Thank you!
September 25th, 2007 on 8:04 am
Holly C., the plugin work a only when theres no picture at the beginning of a post
September 26th, 2007 on 10:42 am
It worked like a charm. I made one tweak of the style sheet, changing the color of the drop cap to a darker gray. I used #666666. But I am truly grateful for the beauty and simplicity of this plugin. Thanks
September 29th, 2007 on 4:38 pm
The first character (Drop Cap) displays perfectly, but the other letters display next to the title. Take a look at my blog: http://www.seriousaboutwine.co.za & the posts 28 Sept, 27 Sept & 21 Sept. Can anyone assist me?
October 8th, 2007 on 12:32 pm
Awesome! Thank you so much!
October 13th, 2007 on 3:18 pm
rerer
October 15th, 2007 on 4:08 am
@Rodney
this’s absolutely a great wp plugin, its work prefectly on wp 2.3 … but i think this plugin will become more great plugin if it makes the first character of the post BIG not only in the first paragraph, but makes the first character of the post BIG in all paragraphp, generally likes in microsoft office word.
so, can you tell me how to do that?
Thanks,
K
October 16th, 2007 on 8:01 am
Si me funciona el plugin – Esta genial – gracias
October 17th, 2007 on 11:49 am
good!
November 1st, 2007 on 4:25 am
Hi –
For some reason your great plugin is not working over at WebHelperMagazine.com. It is installed and activated — but the drop caps do not appear. I am using the theme, “Fluid Blue” — it should be up to date (see: http://srinig.com/wordpress-themes/fluid-blue/)
Any suggestions?
Thanks, Scott
November 22nd, 2007 on 2:39 am
thanks for the GREAT post! Very useful…
November 24th, 2007 on 3:57 am
Great plug in but I also love the comments section. Did you create this plug in as well?
Thanks so much.
January 2nd, 2008 on 6:46 am
It works perfectly! thanks for putting time and effort into it!
January 15th, 2008 on 2:48 pm
Is there a way to put something in the post code so that only certain posts have the drop cap?
January 23rd, 2008 on 7:51 am
It’s pushing the word the drop cap is associated with to the far right on top of the posts title. I LOVE this plug in and would like some advice on how to fix this.
February 3rd, 2008 on 4:02 pm
Hello !
Thanks for this GREAT plugin !
Works perfect !
But… I’m trying to use it with another great process : http://www.truefontfamily.com/
Truefontfamily help us to use TTF fonts.
Here I read that “Using the CSS to set the font-family with one of your TrueType fonts. Be sure to replace the dot in .ttf with a space: Font.ttf becomes Font ttf.”
Ok.
Then I modify the dropcap_style.css adding this : font-family: “myfont ttf”;
But that doesn’t match… If I try to use Truefontfamily with another part of my weblog it’s ok, the text shows with my TTF. But I can’t fix it to work with the dropcap_style.css…
Do you have any idea ?
Thanks ! Cheers !
February 9th, 2008 on 6:11 am
Wow! A truly great plugin.
Thanks very much.
March 14th, 2008 on 4:37 pm
this wordpress plugin is excellent,i have used it long time,thank you very much
March 22nd, 2008 on 7:31 am
If you want to see it in action then I use this on http://crn-web.com
Many thanks for this – saved me ages adjusting the CSS – good job!
April 13th, 2008 on 6:35 am
When I choose the first character disappears.
Any suggestions to get DropCap to work when its block justified?
Thanks,
Pierre Miró
http://www.elpobrecitoveedor.net/blog/
April 13th, 2008 on 6:38 am
When I choose to “block justify” the post, the first character disappears.
Any suggestions to get DropCap to work when its block justified?
Thanks,
Pierre Miró
http://www.elpobrecitoveedor.net/blog/
April 13th, 2008 on 11:31 am
I wanted to let you know that as of version 1.1, the Grayplicity theme will be including some of your code from this plugin by default. All credit and licensing text is included intact. See link above for theme.
June 25th, 2008 on 4:34 am
Hi there,
Know anyone which plugin to use if I want only a part of the article to be displayed? If someone want to read more there will be a “read more” link…
On my blog right now is displayed all of article content and I don’t want this…
I’m talking about the latest 10 articles displayed on the first page of my blog.
I’m using WordPress.
Can anyone help?
July 13th, 2008 on 1:08 pm
Thanks for the plugin. It is great. I am using it on this blog/online magazine:
My question: How can I disable it on pages but keep it active on posts? Can you add a “Preferences” page under the “Setting” in Admin?
July 13th, 2008 on 1:08 pm
Thanks for the plugin. It is great. I am using it on this blog/online magazine:
http://thepublicsphere.com/
My question: How can I disable it on pages but keep it active on posts? Can you add a “Preferences” page under the “Setting” in Admin?
September 9th, 2008 on 12:41 pm
Great little plugin!!!
October 8th, 2008 on 10:18 pm
Nice plugin I guess, besides cool information, a blog should has the aesthetic touch too.
October 14th, 2008 on 2:16 pm
Hi,
The only place the initial cap shows is on this page. How can I get it to show on all my pages and posts?
It is beautiful!
Patricia
October 30th, 2008 on 1:22 am
Thank you so much.
November 8th, 2008 on 2:02 pm
Thank you! This works with UTF8, unlike other plugins.
December 2nd, 2008 on 11:35 pm
The pluin support Chinese_zh.
对中文支持非常好,
谢了。
December 12th, 2008 on 5:55 pm
Q: Supported WP 2.7?.. 🙂
December 29th, 2008 on 3:38 am
Hi: Thanks for this cool little plugin. I always like dropcap and this one is very nicely designed.
http://www.iamparis.com/wordpress
January 23rd, 2009 on 4:45 pm
Looks like a great plugin, i will be trying it on my blog for sure.
January 30th, 2009 on 5:40 pm
Хех.. какой-то оффтопик начался 🙂
February 4th, 2009 on 9:55 pm
Ух ты! Интересный поворот событий!
February 5th, 2009 on 9:27 am
Appears to be yes 🙂
February 13th, 2009 on 7:54 am
does not work on category page
February 25th, 2009 on 2:12 am
The plugin is awesome; however, it doesn’t display correctly in Safari. It looks great in FireFox. You can check here: http://michaelhyatt.com.
May 9th, 2009 on 11:28 pm
Спасибо Вам огромное
May 13th, 2009 on 10:59 am
nice plugin
I already use it and running well
June 10th, 2009 on 6:51 pm
Плагін працює на російскій або українскій версіїї ordpress?
June 10th, 2009 on 6:52 pm
Цікаво, чи працює плагін на російскій або українскій версії wordpress?
June 17th, 2009 on 2:02 am
thankssss
June 18th, 2009 on 7:16 pm
thankssss.
August 13th, 2009 on 9:44 am
This worked so easily and is soooo easy to adapt to my theme in progress in which I will give you mention when I have it up and running.
http://inspirations.cosmicthings.com.
Thank you.
August 30th, 2009 on 4:23 am
I installed and activated the plug in and nothing changed. What’s up?
September 5th, 2009 on 12:28 am
cool idea
thanks…
November 24th, 2009 on 1:11 am
Great Plugin.
You can check it in our posts.
http://www.freakyclip.com
January 9th, 2010 on 6:14 am
Great plug-in! Works perfect for WP 2.9.1.
February 23rd, 2010 on 8:12 am
Can you provide more information on other wordpress plugins, or do you have some resources you can share with us where we can find such useful stuff? Thanks.
February 24th, 2010 on 12:47 am
It’s a great plugin! I used to do first big letter manually for each post, but it takes time (I used span class=”letter”, style was in style.css).
But now I can do it once, installing your plugin, and it’s wonderful. Thanks a lot.
February 26th, 2010 on 9:06 am
Rodney (that’s my name too by the way), thanks for making this plugin. I just put it on my blog and I changed the color to black. Looks pretty good.
Here’s a live example:
http://www.sat-essay.net/sat-essay/
March 11th, 2010 on 9:52 pm
Great plugin it works perfectly with WordPress 2.9.2 which is great. i personally love it. Thanks for the plugin.
March 21st, 2010 on 1:04 pm
keresn abisss…..thank for this…..
May 9th, 2010 on 2:03 pm
I do not understand … but it does not matter …. as the science of information …. thanks
May 13th, 2010 on 3:14 am
Beautiful. Why don’t you put this in the WordPress plugin directory? I couldn’t find it there and it is much better and cleaner and leaner then the one that is there!
June 15th, 2010 on 9:19 pm
is this plug is usefull for incrase trafic or SEO?
June 15th, 2010 on 9:20 pm
i thinks this is usefull for performance my blog, n sooo nice looks
August 17th, 2010 on 5:36 am
Я надеюсь завтра будет…
В этом что-то есть. Понятно, большое спасибо за помощь в этом вопросе.
Согласен!
Я конечно, прошу прощения, но это мне совершенно не подходит. Кто еще, что может подсказать?
Я извиняюсь, но, по-моему, Вы не правы. Давайте обсудим это. Пишите мне в PM.
August 21st, 2010 on 3:36 am
nice share, i’ve looking for this code how to make drop down cat in wordpress. thanks
August 21st, 2010 on 10:15 am
Thanks for this plugin. I will have to give it a try.
August 22nd, 2010 on 7:05 pm
Clothes Store makes online shopping a snap with a suggestion tool, easy searching and this season’s must-haves. Shop women’s and men’s clothes now.
August 23rd, 2010 on 6:36 am
Вы топик читали?
Вы допускаете ошибку. Могу отстоять свою позицию. Пишите мне в PM, пообщаемся.
это просто ужасно!!!!!
не очень:!
Чудесно!
August 25th, 2010 on 9:58 pm
Полностью разделяю Ваше мнение. В этом что-то есть и идея отличная, поддерживаю.
Тьфу ты, туфта!
нормуль,давно искал! всем спасибо…
ничего особенного
Я Вам очень благодарен за информацию. Я воспользовался этим.
August 29th, 2010 on 2:24 am
Да, логически правильно
В этом что-то есть. Благодарю Вас за помощь, как я могу отблагодарить?
Замечательно, очень ценная фраза
Клево!!! Вечером обязательно посмотрю
Об этом не может быть и речи.
October 5th, 2010 on 10:30 pm
Как выигрывать в Starcraft 2 по сети – http://combains.ru/igry-dlya-pc/14-sovetov-po-taktike-v-starcraft-2/ – советы про-геймеров!
November 29th, 2010 on 8:26 am
I got the dropcap to work, but it is in every posting.
How might I adjust the code so that I could insert a dropcap rather than having the code do so automatically?
How do I adjust the code so that the dropcap feature could also apply to pages?
I like the style! I like what you did!
December 24th, 2010 on 6:49 pm
“get_bloginfo(‘wpurl’) . ‘/wp-content/plugins/dropcap_first/dropcap_style.”
How much is realistic?
December 28th, 2010 on 3:35 am
For some reason, the plugin was working, and now it is not, after I added another post it is not doing the DROPCAPS.
ANy solutions?
I did notice that the plugin is loading on the same line of code as another plugin, but I dont know if that matters…
thanks
January 4th, 2011 on 11:02 am
This plugin does not work on my WordPress site.
April 1st, 2011 on 5:25 am
There is a version for the usual sites?
April 30th, 2011 on 11:37 pm
still being maintained? compatible with wp 3.1.2?
May 2nd, 2011 on 8:39 pm
Yes still compatible with 3.1.2 (thats what I’m currently using on this blog).
July 20th, 2011 on 1:50 am
Nice!..thanks
August 12th, 2011 on 9:43 am
Hi!
(sry for my poor english, I’m from France)
I’m actually using your (excellent) plug-in, but I want to wrap text aroud image in the same time. So I use this plug-in: http://codex.wordpress.org/Wrapping_Text_Around_Images . And if I set up this plug-in, your’s doesn’t work anymore.
Do you have an idea? Thanks you!
Pierre.
September 15th, 2011 on 5:55 pm
Exactly what I am looking for, thanks for creating this wonderful plugin. It’s Awesome!
October 7th, 2011 on 8:55 am
Hi Rodney!
Gigantic thanks for making a Drop Cap plug-in that actually works with å, ä and ö (Swedish letters)!! =D
The only instance where it doesn’t show is when an image comes before the first paragraph. Not sure why the image is considered a though =\
But, apart from that I’m extremely thankful for your brilliant work! =D
Best wishes!
February 17th, 2012 on 5:03 am
Great! Love it!
April 4th, 2012 on 11:48 pm
Посетите сайт : http://pandorum.org/
Visit the website : http://pandorum.org/
Хорошее дается тому кто умеет ждать…
Pro WordPress и не только.
Pro | PHP скрипты для сайта.
Pro | Премиум темы и шаблоны.
Pro | Премиум плагины WordPress.
December 28th, 2012 on 10:56 am
[…] DropCap First Character – Hace más grande la primera letra de tus artículos dando un efecto muy común en […]