AnsPress_Theme::get_the_excerpt( string $excerpt, object|null $post = null )
Description #
Generate question excerpt if there is not any already.
Parameters #
- $excerptstring (Required) Default excerpt.
- $postobject | null (Optional) WP_Post object. Default value: null
Source #
File: includes/class-theme.php
public static function get_the_excerpt( $excerpt, $post = null ) {
$post = get_post( $post );
if ( 'question' === $post->post_type ) {
if ( get_query_var( 'answer_id' ) ) {
$post = ap_get_post( get_query_var( 'answer_id' ) );
}
// Check if excerpt exists.
if ( ! empty( $post->post_excerpt ) ) {
return $post->post_excerpt;
}
$excerpt_length = apply_filters( 'excerpt_length', 55 );
$excerpt_more = apply_filters( 'excerpt_more', ' […]' );
return wp_trim_words( $post->post_content, $excerpt_length, $excerpt_more );
}
return $excerpt;
}
Expand full source code Collapse full source code View on GitHub: includes/class-theme.php:310
Add your comment