Support » Plugin: Yoast SEO » meta property="og:locale" content="en_US"

Viewing 15 replies - 1 through 15 (of 15 total)
  • Thread Starter keychange

    (@keychange)

    No response – it appears that I have wasted a lot of time editing posts – correct geolocation is very important for some of my sites.

    I have looked through your fles and cannot find the reference which I simply want deleted

    The reason is that Facebook does not support the en-AU locale. The plugin checks is for that.

    You can filter the output though using the wpseo_og_og_locale filter.

    Thread Starter keychange

    (@keychange)

    Thanks JRF – I get function not found error

    Thread Starter keychange

    (@keychange)

    Wow way too tedious I am not editing every one of my Australian WP instalsl to fix that. I will look for alternative solutions 🙁

    Good luck. Please mark the topic as resolved as you have the solution for WP SEO.

    Thread Starter keychange

    (@keychange)

    not sure I would describe this as solved, the work around is tedious when you have multiple sites and I didn’t resolve the function not found error. I know I can resolve it with time but I think it will be easier to find another plugin – after all it is the Yoast plugin that is inserting the meta code

    And there was me thinking you actually figured out what to do with wpseo_og_og_locale….

    *sigh* as I said, it’s a *filter*. Like most of WordPress works on filters… i.e. not a function.

    To use it, you should add an add_filter() call in your (child-)theme’s functions.php file and also add the function the filter will call to change the data.

    So again, your question is answered, problem solved. That you don’t want to apply the solution is your choice, but does not make the topic any less solved.

    Thread Starter keychange

    (@keychange)

    No need to be condescending, I have not been rude to you – I know it is a filter and I added the filter add_filter “(‘wpseo_locale’, ‘en_au’);” to functions.php – if that was incorrect forgive me but I could find no other instructions.

    Actually you have been rude to me. I’m voluntarily trying to help you, and before even trying to understand what I said, you started calling it ‘tedious’ and complaining about a *free* plugin, a plugin I should say on which people are (again) *voluntarily* spending a lot of their valuable time to build & maintain it.

    You clearly haven’t even bothered to look at the WP documentation which actually explains how to add filters or you would have known that you are doing it wrong.

    Thread Starter keychange

    (@keychange)

    I am sorry I did not mean to be rude to you personally – the solution is tedious for 30 + installs.

    I have read the documentation – but I cannot claim that I fully understood it, that is not my fault, I have to live with my limitations.

    Fair enough. Have a look at the below and yes, having to add this to 30+ sites will be tedious, but then again, you’re doing something which will break your facebook locale recognition, so that’s your choice.

    add_filter( 'wpseo_og_og_locale', 'my_locale_filter' );
    function my_locale_filter( $locale ) {
    	if( $locale === 'en_US' && get_locale() !== 'en_US' ) {
    		$locale = get_locale();
    	}
    	return $locale;
    }

    or if you want to get rid of the locale tag altogether:

    add_filter( 'wpseo_og_og_locale', 'my_locale_filter' );
    function my_locale_filter( $locale ) {
    	return '';
    }

    Oh … and being rude on fora – whether it was meant personally or not – is never a good idea.

    Thread Starter keychange

    (@keychange)

    Thanks for that.

    Keep in mind that the language code needs to be part of Facebooks set of codes:

    'ca_ES', 'cs_CZ', 'cy_GB', 'da_DK', 'de_DE', 'eu_ES', 'en_PI', 'en_UD', 'ck_US', 'en_US', 'es_LA', 'es_CL', 'es_CO', 'es_ES', 'es_MX',
    'es_VE', 'fb_FI', 'fi_FI', 'fr_FR', 'gl_ES', 'hu_HU', 'it_IT', 'ja_JP', 'ko_KR', 'nb_NO', 'nn_NO', 'nl_NL', 'pl_PL', 'pt_BR', 'pt_PT',
    'ro_RO', 'ru_RU', 'sk_SK', 'sl_SI', 'sv_SE', 'th_TH', 'tr_TR', 'ku_TR', 'zh_CN', 'zh_HK', 'zh_TW', 'fb_LT', 'af_ZA', 'sq_AL', 'hy_AM',
    'az_AZ', 'be_BY', 'bn_IN', 'bs_BA', 'bg_BG', 'hr_HR', 'nl_BE', 'en_GB', 'eo_EO', 'et_EE', 'fo_FO', 'fr_CA', 'ka_GE', 'el_GR', 'gu_IN',
    'hi_IN', 'is_IS', 'id_ID', 'ga_IE', 'jv_ID', 'kn_IN', 'kk_KZ', 'la_VA', 'lv_LV', 'li_NL', 'lt_LT', 'mk_MK', 'mg_MG', 'ms_MY', 'mt_MT',
    'mr_IN', 'mn_MN', 'ne_NP', 'pa_IN', 'rm_CH', 'sa_IN', 'sr_RS', 'so_SO', 'sw_KE', 'tl_PH', 'ta_IN', 'tt_RU', 'te_IN', 'ml_IN', 'uk_UA',
    'uz_UZ', 'vi_VN', 'xh_ZA', 'zu_ZA', 'km_KH', 'tg_TJ', 'ar_AR', 'he_IL', 'ur_PK', 'fa_IR', 'sy_SY', 'yi_DE', 'gn_PY', 'qu_PE', 'ay_BO',
    'se_NO', 'ps_AF', 'tl_ST'

    Example: en_CA won’t work as it’s not part of the list. In this case Yoast’s plugin would use the default WP lang, e.g. en_US

    I have a site which has exactly one page per language. So I adopted this function here, just in case someone needs it:

    add_filter('wpseo_locale', 'override_og_locale');
    function override_og_locale($locale)
    {
    	if ( is_page( 781 ) ) {
        	return "de_DE";
    	}
    	elseif ( is_page( 783 ) ) {
        	return "sv_SE";
    	}
    	elseif ( is_page( '566' ) ) {
        	return "pl_PL";
    	}
    	elseif ( is_page( '567' ) ) {
       		return "it_IT";
    	}
    	elseif ( is_page( '234' ) ) {
        	return "es_ES";
    	}
    	elseif ( is_page( '345' ) ) {
        	return "fr_FR";
    	}
    	elseif ( is_page( '456' ) ) {
        	return "fi_FI";
    	}
    	elseif ( is_page( '567' ) ) {
        	return "no_NO)";
    	}
    	elseif ( is_page( '678' ) ) {
        	return "dk_DK";
    	}
    	else {
       		return "en_GB";
    	}
    }

    Excuse me for digging up an old post, but this is not locked and my site is also set to “en_AU” (that’s the WordPress version I’m using too)!
    I understand ZERO PHP, but fairly well HTML and the rest of the implications. From reading here and elsewhere I understand “en_AU” is not a valid locale for Facebook (we’re only a “tiny island” after all, the size of Texas as some American once tried to convince me…), so I should not use this! BUT: we also spell things correctly, certainly DIFFERENTLY! So can I use “en_GB” for Great Britain, home of our great Queen and spelling roots?

    Would the following code be correct (just trying to verify the PHP)?

    add_filter( 'wpseo_og_og_locale', 'my_locale_filter' );
    function my_locale_filter( $locale ) {
    	if( $locale === 'en_US' && get_locale() !== 'en_US' ) {
    		$locale = get_locale();
    	}
    	return "en_GB";
    }

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘meta property="og:locale" content="en_US"’ is closed to new replies.