• Resolved subtire

    (@subtire)


    Hello,

    Anytime when I use the [dropcap]text[/dropcap] function, the first letter is cut out of the short description on my WP site. Is there any solution for this problem?

    Thanks you!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hi subtire. Could you post a link to your site so we can see the problem? Thanks.

    Thread Starter subtire

    (@subtire)

    Sure, sorry, I fotgot to to that in the first post: http://travel210.com/

    Hey there subtire,

    Have you tried using post excerpt? You can turn it on by checking Excerpt in Screen Options http://screencast.com/t/aJMZjZyiaQjg. After that simply insert text in the Excerpt field, that text should be displayed on your post page for that specific post where you don’t use dropcap shortcode so your text can be displayed properly.

    Hope this helps.

    Best regards,
    Bojan

    Hi subtire. That is indeed strange. It appears that the shortcode isn’t being parsed correctly in the post summary; the summary is missing the span element that is created by the shortcode. I tried using the shortcode in an excerpt and the shortcode doesn’t appear to be recognized as such because it’s displayed as part of the excerpt text. I’ll dig around and see if I can find a fix.

    It may be that it’s being parsed out of the the summary, which it should be, but it’s taking the text with it. And it’s not just the dropcap shortcode; it happens with others as well. Still looking.

    Thread Starter subtire

    (@subtire)

    Hello Bojan,

    Thank you for the reply, I will try that on my future posts but I really need a general solution because I have about 200+ posts, most of them begin with [dropcap][/dropcap] and I think that it’s a lot of manual work for me to go back and edit almost every post.

    Hello again bdbrown,

    Yes, it seems that most of the shortcodes [dropcap], [column] are not ok with the short description, they only work on the single.php page. 🙁
    If you begin your post with a [column], the text inside the column will not display at all in the short description… and, as we already know, neither the letters inside the [dropcap][/dropcap]

    Thanks again!

    You shouldn’t have to create an excerpt just to work around the problem. That will quickly become a maintenance headache. I tested it in Twenty Fourteen and that theme does handle the shortcodes by interpreting them correctly, even within the post summary. So it appears to be something within Hueman.

    Thread Starter subtire

    (@subtire)

    Maybe Alexander Agnarson can do something about this.

    I did some more research. Hueman is actually using the default WP functionality for the excerpt which is, if there is a user-defined excerpt, return that unchanged, otherwise return a automatically generated trimmed-down version of the full post content which has all shortcodes and tags removed. So, that explains why the shortcode shows up as part of the content in a user-defined excerpt, but gets stripped out of the excerprt that is automatically-generated from the post content. If you’re interested in the specifics, here is the Codex reference for “the_excerpt” function that Hueman uses.

    The fix is to override the default functionality with a user function to strip the shortcodes but keep the content, which I found here:

    function custom_excerpt($text = '') {
    	$raw_excerpt = $text;
    	if ( '' == $text ) {
    		$text = get_the_content('');
                    // $text = strip_shortcodes( $text );
    		$text = do_shortcode( $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);
    }
    remove_filter( 'get_the_excerpt', 'wp_trim_excerpt'  );
    add_filter( 'get_the_excerpt', 'custom_excerpt'  );

    It worked on my test system. Let me know if it works for you.

    Thread Starter subtire

    (@subtire)

    Thank you very much bdbrown!

    It works like a charm!

    I added the function to functions.php and it works!

    Thank you!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[dropcap]text[/dropcap] help’ is closed to new replies.