Remove Reading Time WP From Rank Math
-
Hello,
do you have a customized version for Rank Math?
`/**
* A Function to remove the auto generated Reading Time from Yoast og:desc
*
* This hooks into Yoast’swpseo_opengraph_desc
filter and uses a regular
* expression to remove the reading time for the post
*
* @see Reading Time WP Plugin
* @link https://www.ads-software.com/plugins/reading-time-wp/
*
* @param string $ogdesc The excerpt grabbed by Yoast for output.
* @return string The $ogdesc with the Reading Time string removed.
*/
function remove_reading_time_from_yoast( $ogdesc ) {//First we get the options set on this version of Reading Time WP
$rtwp_options = get_option(‘rt_reading_time_options’);
$rtwp_label = $rtwp_options[‘label’];
$rtwp_postfix = $rtwp_options[‘postfix’];
$rtwp_singular = $rtwp_options[‘postfix_singular’];// Next we build a regular expression using those options
$rtwp_regex = $rtwp_label . ‘(.*?)(‘ . $rtwp_postfix . ‘|’ . $rtwp_singular . ‘)’;// Finally we use
preg_replace
to replace the reading time with an empty string
$ogdesc = preg_replace(‘/’ . $rtwp_regex . ‘/’, ”, $ogdesc);return $ogdesc;
}add_filter( ‘wpseo_opengraph_desc’, ‘remove_reading_time_from_yoast’ );
- The topic ‘Remove Reading Time WP From Rank Math’ is closed to new replies.