Skip to content

Instantly share code, notes, and snippets.

@mihdan
Last active April 30, 2021 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mihdan/c3c3575ab552089b111ee5f05631d62c to your computer and use it in GitHub Desktop.
Save mihdan/c3c3575ab552089b111ee5f05631d62c to your computer and use it in GitHub Desktop.
Yoast SEO: register extra replacement to get content before read more tag
<?php
add_action(
'wpseo_register_extra_replacements',
/**
* Yoast SEO: register extra replacement to get content before read more tag
*/
function () {
wpseo_register_var_replacement(
'%%read_more%%',
function () {
return wp_strip_all_tags( get_extended( get_post()->post_content )['main'] );
},
'advanced',
'Get content before read more tag'
);
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment