How to re-use Yoast meta in page template?
-
Hi! I’m trying to re-use my Yoast meta description into a structured data description field by adding it to my page template.
I found online someone said I could get the Yoast meta using:
get_post_meta($post->ID, ‘_yoast_wpseo_metadesc’, true);
However, when I add this to my echo statement, which looks like so:
$yoast_meta = get_post_meta($post->ID, '_yoast_wpseo_metadesc', true); function my_service_template_footer_data() { echo "<script type='application/ld+json'> { '@context': 'https://schema.org/', '@type': 'Service', 'serviceType': ' " . get_the_title() . " ', 'description': ' " . $yoast_meta . " ', 'provider': { '@type': 'LocalBusiness', ...ETC...
I get the following error from WP DEBUG:
Parse error: syntax error, unexpected ‘.’ in /home/x/y/public_html/wp-content/themes/twentytwentyone-child/functions.php on line 99
Any tips to get this working? Thanks so much!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to re-use Yoast meta in page template?’ is closed to new replies.