Skip Navigation

[Resolved] figcaption appearing in excerpt?!

This support ticket is created 3 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 6 replies, has 2 voices.

Last updated by TorstenR3514 3 years, 2 months ago.

Assisted by: Waqar.

Author
Posts
#2162397

figcaptions shouldn't appear in excerpts right?
see Grapefruit in view: hidden link

Also could reproduce the same on https://discover-wp.com/

Is there any documentation that you are following?
hidden link

Is there a similar example that we can see?
That's the way it should be, no figcaption, and a space after the headline.
Kadence Post Archive hidden link

Would be great to be able to exclude tag from excerpt orlimit to some.

Greetings Torsten

#2162625

Hi Torsten,

Thank you for contacting us and I'd be happy to assist.

To exclude the text from the image caption and other HTML tags, you can register a custom shortcode, for example:


add_shortcode('custom-show-excerpt', 'custom_show_excerpt_fn');
function custom_show_excerpt_fn() {
	ob_start();
	echo the_excerpt();		
	return ob_get_clean();
}

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

After that, you'll be able to show the excerpt using this custom shortcode, like this:


[custom-show-excerpt]

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2162637

Thx Waqar,

that works, but how can I set length by word/charakter?

And if possible set the "elipse text".

Is there any documentation what is cleaned with the above shortcode?

#2162851

Thanks for the update and glad that it worked.

Since, this custom shortcode is using the WordPress' built-in "the_excerpt" function, to customize its output, you'll need to use other WordPress excerpt filters.

For example, to adjust the word count, you'll additionally add:


function custom_excerpt_length( $length ) {
	// set excerpt length to 20 words
	return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

And for the excerpt read more text:


function custom_excerpt_more( $more ) {
	return sprintf( '.... <a href="%1$s" class="more-link">%2$s</a>',
		esc_url( get_permalink( get_the_ID() ) ),
		sprintf( __( 'Continue reading %s', 'theme-name' ), '<span class="screen-reader-text">' . get_the_title( get_the_ID() ) . '</span>' )
	);
}
add_filter( 'excerpt_more', 'custom_excerpt_more' );

You can read the details about the functions and filters used in these snippets from these links:
https://developer.wordpress.org/reference/functions/the_excerpt/
https://developer.wordpress.org/reference/hooks/excerpt_length/
https://developer.wordpress.org/reference/hooks/excerpt_more/

Note: The custom code examples from our forum are shared to get you started in the right direction. You're welcome to adjust them as needed and for more personalized customization assistance, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/

#2165451
Fieldoptions-Excerpt.png

If I end up using the WordPress standard excerpt and need to set the same word count for all excerpt, I can use the WP Post Excerpt block instead, which seems to do a better job than the Toolset block.

hidden link

Since the ability to individually set wordcount in views is a great feature, I hope that we can make these settings in the toolset block in the future (see picture)

I know, propably not because of ... but I'll keep dreaming.

#2167657

Thank you for sharing this feedback and please feel free to submit this as a feature request:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

You're welcome to mark this ticket as resolved and start a new one for each new question or concern.

#2167675

My issue is resolved now. Thank you!