Yoast meta | WordPress.org

[ad_1]

Hello @snoop23,

This block supports displaying any field whose value can be retrieved by the core API (get_post_metaget_term_metaget_user_meta) and is a string or can be converted to a string. So if those Yoast meta keys can be retrieved via above core APIs then they can be displayed with this block. If they are not compatibble with core APIs, you also can disaplay them via custom code. I’m not familar with Yoast API to provide a final snippet but here is what the code might look like:

add_filter( 'meta_field_block_get_block_content', function ( $block_content, $attributes, $block, $post_id, $object_type ) {
$field_name = $attributes['fieldName'] ?? '';

if ( 'your_field_name' === $field_name ) {
// Using Yoast SEO API to get value here, then override the $block_content with your desired format.
// $block_content="new value here";
}

return $block_content;
}, 10, 5);

Best, Phi.

Okay, cool. That’s very helpful.

Thanks for the quick and detailed response. Much appreciated.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer