ข้ามการนำทาง

Open

Reported for: WPML SEO 2.1.1

Topic Tags: Compatibility

Overview of the issue

When using Yoast SEO, the plugin automatically adds Open Graph meta tags to the head section of author archive pages. However, on translated author archive pages, the og:url meta tag will display the URL in the default language.

Workaround

Please, make sure of having a full site backup of your site before proceeding.

  • Open your theme’s functions.php file.
    /**
     * Workaround to fix og:url meta tag on translations of author archives
     */
    add_filter( 'wpseo_opengraph_url', function($url, $presentation){
    
    	if ( $presentation instanceof YoastWPSEOPresentationsIndexable_Author_Archive_Presentation ){
    		$user_id = $presentation->source['post_author'];
    		$url = rawurlencode( get_author_posts_url($user_id) );
    	}
    
    	return $url;
    }, 10, 2 );
            

ทิ้งคำตอบไว้

โปรดอยู่ในหัวข้อและเคารพผู้อื่น หากคุณต้องการความช่วยเหลือเกี่ยวกับปัญหาที่ไม่เกี่ยวข้องกับโพสต์นี้ โปรดใช้ฟอรัมสนับสนุนของเราเพื่อเริ่มการสนทนาหรือส่งตั๋ว.

คุณสามารถใช้แท็กเหล่านี้:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>