Filter description in Schema.org

Need help with this?
Purchase All in One SEO Pack Pro to get dedicated support from us.

Buy Now

By default, All in One SEO Pack uses the SEO Description for a post or page as the description in the Schema.org markup.  This filter can be used to change this to the post excerpt or post/page content for all content, all content in a post type, or for a specific post ID.

function aioseop_schema_custom_description( $data ) {
     global $post;

     if( $post->ID === 1 ) {

          // Use post_excerpt below for the excerpt
          $description = $post->post_content; 

          $data['description'] = $description;
     }
     return $data;

}

// Filter for WebPage schema type
add_filter( 'aioseop_schema_class_data_AIOSEOP_Graph_WebPage', 'aioseop_schema_custom_description' );

//Filter for Article schema type
add_filter( 'aioseop_schema_class_data_AIOSEOP_Graph_Article', 'aioseop_schema_custom_description' );

 

For instructions on how to use this code, please refer to our FAQ here.