This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'get_the_excerpt', function ( $excerpt, $post ) { | |
if ( ! empty( $excerpt ) ) { | |
return $excerpt; | |
} | |
// On a specific post type, use an ACF field value as the excerpt. | |
if ( $post->post_type === 'my_custom_post_type' ) { | |
$excerpt = get_field( 'product_description', $post->ID ); | |
} | |
return $excerpt; | |
}, 10, 2 ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment