Skip to content

Instantly share code, notes, and snippets.

@schemapress
Created September 28, 2017 18:23
Show Gist options
  • Save schemapress/b1af7ad8189ab05f3819dc9cd67f75d7 to your computer and use it in GitHub Desktop.
Save schemapress/b1af7ad8189ab05f3819dc9cd67f75d7 to your computer and use it in GitHub Desktop.
Add articleBody to Schema Output in Schema Plugin https://schema.press
<?php //* do not include php tag
add_filter('schema_output', 'schema_wp_extend_output_articleBody_98738765');
/**
* Add articleBody to Schema Output
*
* @since 1.0
*/
function schema_wp_extend_output_articleBody_98738765( $schema ) {
global $post;
if ( empty($schema) ) return;
// Add articleBody
// $schema['articleBody'] = 'This is the article body text...';
//
// So, you can do something like this to pull value from post meta
//
// Change YOUR-KEY with the actual post meta key where value is stored
//
$article_body = get_post_meta( $post->ID, 'YOUR-KEY', true );
if ( isset($article_body) ) {
$schema['articleBody'] = $article_body;
}
return $schema;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment