Last active
April 5, 2020 19:09
-
-
Save joychetry/97aee5232a39f2fcb6117277d6137c3b to your computer and use it in GitHub Desktop.
Replace Default Post Excerpt to Yoast using Filter
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
add_filter( 'get_the_excerpt', 'replace_post_excerpt_crowwwn' ); | |
function replace_post_excerpt_crowwwn($output) | |
{ | |
$output=get_post_meta(get_the_ID(), '_yoast_wpseo_metadesc', true); | |
if ($output == !NULL) { | |
return $output; | |
} | |
else { | |
$content = get_the_content(); | |
return wp_trim_words( $content , '27' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment