Shortcodes in excerpts returning empty string

If you’re using auto-generated excerpts, then all shortcodes will be removed (https://developer.wordpress.org/reference/functions/the_excerpt/): An auto-generated excerpt will also have all shortcodes and tags removed. It is trimmed down to a word-boundary and the default length is 55 words. For languages in which words are (or can be) described with single characters (ie. East-Asian languages) the word-boundary … Read more

Excerpt using Read More Tag

You just need to set the first argument of the_content() to an empty string: <?php the_content( ” ); ?> If you don’t pass an argument it will use the default, which is a link with the text “(more…)”, but by passing an empty string, the empty string (i.e. nothing) gets displayed instead. If you want … Read more

How to put “Read more” link in Custom Excerpt inside p tag?

One approach is: //… // this is the resulted paragraph without the enclosing <p> and </p> $first_para_inner_text = $matches [1] [1]; // <– the index changed $link = get_permalink($post); // rebuilding the p $first_para=”<p>” . $first_para_inner_text . ‘ <a href=”‘.$link.'”>Read More</a></p>’; echo $first_para; Not tested, but you may get the idea. Just need to modify/change … Read more

Truncating varying lengths of information

I know toscho doesn’t like this very much, but anyway: Converted the input args to an array: function utf8_truncate( $args = array( ‘string’ => null, ‘max_chars’ => 200, ‘append’ => “\xC2\xA0…” ) ) { $args[‘string’] = strip_tags( $args[‘string’] ); $args[‘string’] = html_entity_decode( $args[‘string’], ENT_QUOTES, ‘utf-8’ ); // \xC2\xA0 is the no-break space $args[‘string’] = trim( … Read more

Displaying latest Posts – fixed height – Excerpt vs. Content?

The simple way to do this is to define the height/width in CSS of a container, and then apply a trim on the excerpt. To change default excerpt length add this to you functions.php function new_excerpt_length($length) { return 100; // change this to how many any characters you want } add_filter(‘excerpt_length’, ‘new_excerpt_length’); Manually controlling the … Read more