Home › Forums › General Issues › Include customized excerpt filter with ACF Post Object field › Reply To: Include customized excerpt filter with ACF Post Object field
The hook for get_the_excerpt passes 3 arguments.
apply_filters( 'get_the_excerpt', $post->post_excerpt, $post );
You need a different filter for each of these hooks.
The first line of your filters will need to be different based on the hook
$post_id = ( $post ) ? $post->ID : get_the_ID();
for the “get_the_excerpt” filter you need to look at the 3rd argument $post->ID
This part does not matter in this case because you are not using the function the_excerpt() in this case, but it is something to be aware of. Your filter would not work at all if you used that function in your loop because you are basing it on the global $post value. In your loop over the posts of the post object field you are not altering the global $post and this means that you’re using the wrong post ID in your code. The function the_excerpt() only works on the global $post object.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.