You can use a filter to extend schema output, this example code should give you an idea of how to do that.
And, well… here is the actual code that you can use:
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;
}
Link to code gist.
In Addition: The reason why this isn’t part of the plugin core functionality is that, Google do not have it as a requirement. Also, this will lead to saving the whole post content in the _schema_json post meta field, which has the json-ld output for fast query by the Schema plugin.
I hope this helps.
-
This reply was modified 7 years, 5 months ago by
Hesham Zebida. Reason: provide more details