Filter image in

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 Featured Image for a post or page as the image in the markup.  This filter can be used to change the image for a specific post ID.

function aioseop_schema_custom_image( $data ) {
     global $post;

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

          $image_data = array(
          '@type' => 'ImageObject',
          'url' => '', //Absolute or relative URL can be used
          'width' => 300, // Optional
          'height' => 300, // Optional
          'caption' => 'Image caption', // Optional

          $data['image'] = $image_data;


     return $data;

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

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


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

  • Was this helpful ?
  • YesNo