WordPress.org

Forums

Hueman
[resolved] Dropcap not appearing on blog home page (10 posts)

  1. Illuminatus_PPM
    Member
    Posted 1 year ago #

    Hi Alexander! Thanks for an amazing theme.

    The dropcap shortcode works fine when viewing a single post, but does not seem to appear on snippets or previews, e.g. on the blog home page listing. Is there something we can do about this?

    Thanks!

    Illuminatus

  2. Alexander Agnarson
    Member
    Theme Author

    Posted 1 year ago #

    Thanks! Shortcodes will not appear in excerpts.

    So, if the first character of the excerpt dissapears, go to edit the post, then top right side click "Screen Options" dropdown and enable Excerpt. Then scroll down below the large text field and add your excerpt in the excerpt box without the dropcap there.

  3. Illuminatus_PPM
    Member
    Posted 1 year ago #

    I fixed it by adding the following to the theme's functions.php, under Custom Functions:

    function remove_dropcap_shortcode($text = '') {
    	$raw_excerpt = $text;
    	if ( '' == $text ) {
    		$text = get_the_content('');
    
    		$text = str_replace("[dropcap]","",$text);
    		$text = str_replace("[/dropcap]","",$text);
    
    		$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);
    }
    add_filter( 'get_the_excerpt', 'remove_dropcap_shortcode', 1);

    Feel free to include it in the next update :)

    Edd

  4. Alexander Agnarson
    Member
    Theme Author

    Posted 1 year ago #

    Thanks for sharing! Good stuff :-)

  5. MissMarlboro
    Member
    Posted 1 year ago #

    Thanks for sharing, I was looking for the same thing!

  6. Richzendy
    Member
    Posted 1 year ago #

    Thanks Illuminatus_PPM, your fix really works for me

  7. frasermarlow
    Member
    Posted 1 year ago #

    Superb - thanks Illuminatus_PPM.
    Dr. Agnarson - thanks for the theme. We are all in your debt! I have hugged many people since I downloaded it.

  8. frasermarlow
    Member
    Posted 1 year ago #

    Hi. I am back with a related issue... On the mobile version, drop caps appear in plain text... I.e. They appear as "[dropcap]A[/dropcap]" ... Any clues?

  9. frasermarlow
    Member
    Posted 1 year ago #

    Ah... I see this thread is marked 'Resolved' ... I will open a new one!

  10. comprido
    Member
    Posted 9 months ago #

    nice, thanks!

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags

No tags yet.