탐색 건너뛰기

Open

Reported for: WPML GraphQL 1.0.0

Overview of the issue

If your are employing the WPGraphQL extension, you will notice that for already translated author metadata content, such as first names, WPGraphQL queries continue to return data in the default language.

Workaround

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

  • Open the …/wp-content/plugins/wp-graphql/src/Model/User.php file.
  • Look for line 191.
  • Replace:
    'firstName'                => function () {
    	return ! empty( $this->data->first_name ) ? $this->data->first_name : null;
    },
    
  • With:
    'firstName'                => function () {
    
    	// WPML Workaround for compsupp-7323
    	if ( class_exists('SitePress') ) {
    		$post_language_details = apply_filters( 'wpml_post_language_details', NULL, $this->global_post->ID ) ;
    		$this->data->first_name = apply_filters('wpml_translate_single_string', $this->data->first_name , 'Authors', 'first_name_'.$this->data->ID);
    	}
    
    	return ! empty( $this->data->first_name ) ? $this->data->first_name : null;
    },
    

Note: this workaround may need to be expanded for other strings as nicename, description, etc…

답장을 남겨주세요

주제를 유지하고 다른 사람을 존중하십시오. 이 게시물과 관련 없는 문제에 대한 도움이 필요한 경우 지원 포럼을 사용하여 채팅을 시작하거나 티켓을 제출하십시오.

다음 태그를 사용할 수 있습니다.
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>