Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using a plugin to allow for dropcaps for the first letter in my Wordpress theme. However, the excerpt is cutting off the first letter. For example, a sentence like: "This is a Wordpress install" would display on the front page as "his is a Wordpress install".

I tried stripping out the strip_shortcodes section of the formatting.php but now there is a space before and after the letter so it displays as: " T his is a Wordpress install".

Does anyone know how to either a) make it display the drop cap or b)show the letter normally?

function wp_trim_excerpt($text = '') {
$raw_excerpt = $text;
if ( '' == $text ) {
    $text = get_the_content('');
    //$text = strip_shortcodes( $text );
    $text = apply_filters('the_content', $text);
    $text = str_replace(']]>', ']]>', $text);
    $excerpt_length = apply_filters('excerpt_length', 55);
    $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
    $text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
}
return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);

}

share|improve this question
1  
what plugin exactly are you using? –  Michael Jan 28 '13 at 15:11
    
... and can you post the relevant code? –  s_ha_dum Jan 28 '13 at 15:15
    
I'm using the Lizatom Wordpress plugin. –  Bo Shubinsky Jan 28 '13 at 15:18
add comment

1 Answer

I'm going to give you a hard-coded solution to this problem, rather than using a plugin. If you're heart is set on a plugin that is fine - but this short code is rather simple and hopefully helpful for your purposes.

This code is basically just adding a CSS class to a shortcode.

First, deactivate that plugin.

Paste this in functions.php

// Shortcode: Drop cap
add_shortcode('dropcap', 'dropcap');
function dropcap($atts, $content = null) {
   extract(shortcode_atts(array('link' => '#'), $atts));
   return '<span class="dropcap">' . do_shortcode($content) . '</span>';
}

Use it like this:

[dropcap]K[/dropcap]

Then style it however you please in your stylesheet:

.dropcap { 
    font-size:50px;
}
share|improve this answer
    
The problem with this is that I use that plugin for other shortcodes that it integrates, so I can't disable it. –  Bo Shubinsky Jan 29 '13 at 19:06
    
That doesn't prevent you from using this code. –  AndrettiMilas Feb 2 '13 at 2:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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