i have a problem with yoast seo plugin; i want to remove the sitename from og:title.
Actually, the meta og:title, show the content that is TITLE OF PAGE – TITLE OF THE SITE.
<meta property="og:title" content="The title of the page or blog - The title of the site" />
How i could remove the sitename, so the og:title show only the title of the page or blog?
public function og_title( $echo = true ) {
if ( is_singular() ) {
$title = WPSEO_Meta::get_value( 'opengraph-title' );
if ( $title === '' ) {
$title = WPSEO_Frontend::get_instance()->title( '' );
}
else {
// Replace WP SEO Variables
$title = wpseo_replace_vars( $title, get_post() );
}
}
else if ( is_front_page() ) {
$title = ( $this->options['og_frontpage_title'] !== '' ) ? $this->options['og_frontpage_title'] : WPSEO_Frontend::get_instance()->title( '' );
}
else {
$title = WPSEO_Frontend::get_instance()->title( '' );
}
/**
* Filter: 'wpseo_opengraph_title' - Allow changing the title specifically for OpenGraph
*
* @api string $unsigned The title string
*/
$title = trim( apply_filters( 'wpseo_opengraph_title', $title ) );
if ( is_string( $title ) && $title !== '' ) {
if ( $echo !== false ) {
$this->og_tag( 'og:title', $title );
return true;
}
}
if ( $echo === false ) {
return $title;
}
return false;
}
thank you
There is a filter that you can use to modify the og title in Yoast SEO plugin: wpseo_opengraph_title
Add this function to your functions.php. If necessary, replace the sepparator character.