aioseo_social_meta_tags

Purpose

This filter can be used to filter the social meta tags All in One SEO outputs.

Arguments (1)

  1. $socialMeta (array) – The social meta tags.
$attributes = [
	'og:site_name'        => '',
	'og:type'             => '',
	'og:title'            => '',
	'og:description'      => '',
	'og:url'              => '',
	'fb:app_id'           => '',
	'fb_admins'           => '',
	'og:image'            => '',
	'twitter:card'        => '',
	'twitter:site'        => '',
	'twitter:domain'      => '',
	'twitter:title'       => '',
	'twitter:description' => '',
	'twitter:image'       => ''
];

The list of meta tags above is not exhaustive.

Example code snippet

The code snippet below is just an example of how this filter can be used. In the example below, the Open Graph and Twitter title for a specific post are changed.

add_filter( 'aioseo_social_meta_tags', 'aioseo_filter_social_meta_tags' );

function aioseo_filter_social_meta_tags( $socialMeta ) {
   if ( is_singular() && '14' === get_the_ID() ) {
      $socialMeta['og:title']      = "A different Open Graph title";
      $socialMeta['twitter:title'] = "A different Twitter title";
   }
   return $socialMeta;
}