• Resolved georgew21

    (@georgew21)


    Hello,

    When I installed wordpress your plugin my language on admin settings was english. As result, I had this value <meta property=”og:locale” content=”en_US” />.

    I changed the language of my site to greek, but en_use value remained.

    Then I followed your site and i add this code to my functions.php file of my theme:

    function yst_wpseo_change_og_locale( $locale ) {
        return 'el_gr';
    }
    
    add_filter( 'wpseo_locale', 'yst_wpseo_change_og_locale' );

    Unfortuntale, I still have this value content=”en_US” and it doesn’t change to greek.

    How I can fix this?

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • @georgew21

    If you don’t want to change the language of your WordPress install but do want to change the locale output of Yoast SEO, you can do so by using the given filter.

    We’ve checked the filter code with the default TwentyTwenty theme and Yoast SEO 17.2.1 and it’s working fine. Make sure that you’ve placed the code on your preferred theme’s functions.php file.

    If the issue still remains, there might be some plugin conflicting or theme.

    Often, we see problems occur in combination with another plugin or theme. The fastest way to rule out any conflict, is to deactivate all non-Yoast plugins and switch to a standard theme like Twenty Twenty.

    Please test this on your development or staging site, if you have one. If not, we recommend using the Health Check & Troubleshooting plugin. This plugin has a troubleshooting mode, which does not affect normal visitors to your site.

    If you’re unfamiliar with checking for conflicts, we’d like to point you to a step-by-step guide that will walk you through the process: How to check for plugin conflicts

    If you do not feel comfortable to do this yourself or if this does not solve your issue, our Yoast SEO Premium plugin comes with one year of (technical) support.`

    Plugin Support Michael Ti?a

    (@mikes41720)

    Hi,

    The og:locale tag should use whatever settings you’ve entered in the WordPress site language settings.

    Otherwise, please do refer to the documentation here for further assistance – https://developer.yoast.com/features/opengraph/api/changing-og-locale-output/

    Thread Starter georgew21

    (@georgew21)

    Well I solved the problem with this way:

    On open-graph-locale-generator.php file, I changed at the end this code :

    if ( ! \in_array( $locale, $fb_valid_fb_locales, true ) ) {
    return ‘en_US’;
    }

    to return “el_GR”.

    Now, it works fine.

    I think that the problem is that on file, the valid code for greek is “el_GR”, while on your guide here : https://developer.yoast.com/features/opengraph/api/changing-og-locale-output/

    you write the greek as “el_gr”. So the difference beetween “el_GR” and “el_gr” has the result to regognise as invalid the value “el_gr” and to have as value “en_US”.

    So, I think you must refresh your values on documentation according to table.

    @georgew21

    It’s glad to know that you’ve managed to resolve the issue. We highly appreciate you for suggesting us to update the developer doc and also we’ve informed our respective team about it. It will get updated soon!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘problem changing og:locale’ is closed to new replies.