@hube2 Thanks! That pointed me in the right direction. I made an amateur mistake and accidentally left off the parameter count on the filter. Once I added the 2 to the get_the_excerpt filter, the $post was passed in correctly and the custom excerpt value worked. Thanks again!
add_filter( 'the_excerpt', 'my_theme_products_and_recipes_excerpt', 10, 1 );
add_filter( 'get_the_excerpt', 'my_theme_products_and_recipes_excerpt', 10, 2 );
@hube2 Thanks for the response. I loop through an ACF Repeater that has a single Clone field of a Post Object:
<?php while ( have_rows( 'my_posts_repeater' ) ) : the_row(); ?>
<?php echo get_sub_field( 'my_clone_field_post_object' )->ID; ?>
<?php echo get_the_excerpt( get_sub_field( 'my_clone_field_post_object' )->ID ); ?>
<?php endwhile; ?>
The ID displays correctly in the example above but the excerpt is empty. Is it possible that the problem is related to using a Clone field as the Post Object?
tjkelly’s solution was also not working for me, but it was because of where I had placed the code snippet. It was apparently too late for admin_init to fire, so the code just wasn’t running at all. For those having trouble, put an echo 'test'; at the top of your function to make sure it’s running.
I changed it to use init instead of admin_init and it worked perfectly for me:
function prefix_reset_metabox_positions(){
delete_user_meta( wp_get_current_user()->ID, 'meta-box-order_post' );
delete_user_meta( wp_get_current_user()->ID, 'meta-box-order_page' );
delete_user_meta( wp_get_current_user()->ID, 'meta-box-order_YOUR_CPT_SLUG' );
}
add_action( 'init', 'prefix_reset_metabox_positions' );
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.