• Resolved kahone85

    (@kahone85)


    Hi,

    My post’s og:title is now same as page title: title + separator + sitename.

    I would like to exclude sitename(and separator) from the title on Facebook share context. I can do that by entering title to the og:title field per post, but because we have lots of authors and lot of content published, I would like to automate that. So what I need is to set the default template for og:title to %%title%%, how to get that done? Is there a filter for that? I searched for settings, but didn’t find default template for og:title.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Michael Tiña

    (@mikes41720)

    If you set a template for the title and meta description for your posts and pages under admin dashboard > SEO (sidebar) > Search Appearance, this should also automatically be what will be used for the og:title and og:meta description if you don’t input a specific title in the Yoast SEO meta box for that post or page.

    To learn more about using variables for your title and meta description templates, please feel free to refer here — https://kb.yoast.com/kb/yoast-wordpress-seo-titles-metas-template-variables/

    Thread Starter kahone85

    (@kahone85)

    Than you for your reply.

    I need more than that. I need two different templates: for document title, it should be:
    %%title%% %%sep%% %%sitename%% and for og:title it should be just %%title%%. If I change it from settings to %%title%%, it will be same in both. If there is a filter for changing document title, then this approach could be viable.

    You can use wpseo_opengraph_title filter to change the open graph title programmatically.

    Thread Starter kahone85

    (@kahone85)

    Thanks, this solves the problem.

    add_filter( 'wpseo_opengraph_title', function($title){
    
    	global $post;
    	
    	$meta = get_post_meta($post->ID, '_yoast_wpseo_opengraph-title', true);
    	
    	// use post title only if og:title is not set
    	if( empty($meta) && !empty($post->post_title) ){
    		$title = $post->post_title;
    	}
    	
    	return $title;
    });
Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘og:title(Facebook) template’ is closed to new replies.