Skip Navigation

[Resolved] using the_excerpt hook with posts block

This support ticket is created 4 years, 1 month 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.

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/Hong_Kong (GMT+08:00)

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 4 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#2109809

Tell us what you are trying to do?
I am using the posts block on a page, but I want to show the content and not just the_excerpt.

I thought I could use a function with "add_filter( 'the_excerpt',...". to modify the excerpt that is rendered by the toolset block. but although the filter works, I can not verify that I am in the correct block, since the global $post variable is not set in the toolset block code. Instead, a private post variable is used, which I can not accessed.

If you were using the_post() with wp_reset_postdata() to clear your loop, I would not have this problem. Honestly, I am surprised you are not doing that, since it was designed to resolve just this situation.

Is there any documentation that you are following?
WP Codex

Is there a similar example that we can see?
https://developer.wordpress.org/reference/functions/wp_reset_postdata/

What is the link to your site?
hidden link - i need to alter what is happening in the announcements section.

#2109969

Hello,

You can try with [wpv-post-excerpt] shortcode, it can retrieve values from post content when post except is empty, and the_excerpt filter hook will apply to it too.

More help:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-excerpt
https://developer.wordpress.org/reference/hooks/the_excerpt/
You can get current post ID with WP function get_the_ID():
https://developer.wordpress.org/reference/functions/get_the_id/
With above post ID, you can get other post information, for example:
https://developer.wordpress.org/reference/functions/get_post/