aioseo_description

Purpose

This filter can be used to filter the description.

Arguments (1)

  1. $description (string) – The description.

Example code snippet

The code snippet below is just an example of how this filter can be used. In the example below, a specific string is appended to the description of each post.

add_filter( 'aioseo_description', 'aioseo_filter_description' );

function aioseo_filter_description( $description ) {
   if ( is_singular() ) {
      return $description . 'some additional description content here';
   }
   return $description;
}

The code snippet below is an example of how this filter can be used to limit the meta description output in the page source code to 160 characters.

add_filter( 'aioseo_description', 'aioseo_truncate_description' );

function aioseo_truncate_description( $description ) {
    if ( function_exists( 'mb_substr') ) {
		return mb_substr( $description, 0, 160 );
	}
	return substr( $description, 0, 160 );
}