# Default Social Image per Post Type in All in One SEO

> Sets a fallback og:image for chosen post types when All in One SEO finds no image for a post.

- Type: PHP
- Runs: Frontend only
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: aioseo, open-graph, images
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/aioseo-og-image-fallback-post-type/

## Code

```php
// Post type => fallback image URL.
$wpide_aioseo_og_fallbacks = array(
    'post' => home_url( '/wp-content/uploads/social-blog.jpg' ),
);

add_filter( 'aioseo_facebook_tags', function ( $tags ) use ( $wpide_aioseo_og_fallbacks ) {
    if ( ! is_array( $tags ) || ! empty( $tags['og:image'] ) || ! is_singular( array_keys( $wpide_aioseo_og_fallbacks ) ) ) {
        return $tags;
    }

    $tags['og:image'] = $wpide_aioseo_og_fallbacks[ get_post_type( get_queried_object_id() ) ];

    return $tags;
} );
```

## Notes

Use images of at least 1200 × 630 pixels.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Default Social Image per Post Type in All in One SEO" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
