Shortcode not rendering in og:title
-
I have a simple shortcode which I use on post titles:
add_shortcode(‘year’, ‘year_shortcode’);
function year_shortcode() {
$year = date(‘Y’);
return $year;
}add_filter( ‘single_post_title’, ‘my_shortcode_title’ );
add_filter( ‘the_title’, ‘my_shortcode_title’ );
add_filter(‘wpseo_title’, ‘my_shortcode_title’);
add_filter( ‘wpseo_metadesc’, ‘my_shortcode_title’ );function my_shortcode_title( $title ){
return do_shortcode( $title );
}
It works fine but I suddenly realized that Yoast creates an og:title and it doesn’t render there (meaning it doesn’t render on Facebook or whatsapp)I searched for an answer and couldn’t find anythinng. Has anyone faced this before?
Maybe I need to run the og:title through a filter of some sort which is also fine, the question is how.
Thanks in advance.
- The topic ‘Shortcode not rendering in og:title’ is closed to new replies.