Skip to content

Instantly share code, notes, and snippets.

@AltanS
Created November 9, 2023 12:32
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 AltanS/30c0d636c98c5ec69e7367f3a592d63d to your computer and use it in GitHub Desktop.
Save AltanS/30c0d636c98c5ec69e7367f3a592d63d to your computer and use it in GitHub Desktop.
YoastSEO WordPress - accessing values in PHP code
<?php
YoastSEO()->meta->for_post($post->ID)->title;
YoastSEO()->meta->for_post($post->ID)->canonical;
// Other values with their default values
// 'canonical' => null,
// 'title' => null,
// 'description' => null,
// 'open_graph_title' => null,
// 'open_graph_image' => 'open_graph_image',
// 'open_graph_image_id' => 'open_graph_image_id',
// 'open_graph_description' => null,
// 'twitter_title' => null,
// 'twitter_image' => 'twitter_image',
// 'twitter_image_id' => null,
// 'twitter_description' => null,
// 'is_cornerstone' => '1',
// 'is_robots_noindex' => null,
// 'is_robots_nofollow' => '0',
// 'is_robots_noarchive' => null,
// 'is_robots_noimageindex' => null,
// 'is_robots_nosnippet' => null,
// 'primary_focus_keyword' => null,
// 'primary_focus_keyword_score' => null,
// 'readability_score' => '50',
// 'inclusive_language_score' => '42',
// 'schema_page_type' => 'FAQPage',
// 'schema_article_type' => 'NewsArticle',
// 'estimated_reading_time_minutes' => '11',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment