Trying to show only manual excerpts, not auto excerpts
-
The theme I’ve been using had a hero banner on posts that used the manual excerpt under the title as an option. A different theme I switched to uses a “page header description” instead, so my need is to have the manual excerpts move over to the “page header description” spot. I have a code function to make that work, but I need some advice.
The code works, except that if there is no manual excerpt on a post, the code pulls up the beginning of the post up to about 200 characters. I want posts that don’t have a manual except to be blank under the title. Here is the code I’m using, and I’d like to know how it could state “if the excerpt is manual, show it; if there’s no manual excerpt, then add nothing”. Thanks for any help you can give. I’ve tried several things, but the only thing I get is either the manual excerpt or the opening of the post on all posts.
/** * Use the excerpt in the page header. * * @param string $description The existing description. * * @return string */ add_filter( 'mai_page_header_description', function( $description ) { if ( is_singular() || ! has_excerpt() ) { $description .= get_the_excerpt( get_the_ID() ); } return $description; });
- The topic ‘Trying to show only manual excerpts, not auto excerpts’ is closed to new replies.