콘텐츠로 건너뛰기 사이드바로 건너뛰기

Waiting for author

Overview of the issue

When using the Posts List Element from Unlimited Elements for Elementor with WPML and Yoast SEO, the module does not display the Yoast Primary Category in translations. Instead, it shows the first category (by alphabetical order) that the post belongs to.

Workaround

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

  • Open the …/wp-content/plugins/unlimited-elements-for-elementor/provider/provider_params_processor.class.php file.
  • Look for the getPostMainCategory function on line 574.
  • Replace:
    	/**
    	 * get post main category from the list of terms
    	 */
    	private function getPostMainCategory($arrTerms, $postID){
    
    		//get term data
    
    		if(count($arrTerms) == 1){		//single
    			$arrTermData = UniteFunctionsUC::getArrFirstValue($arrTerms);
    			return($arrTermData);
    		}
    		
    		$arrMeta = UniteFunctionsWPUC::getPostMeta($postID,true);
    		
    		$mainCategoryID = UniteFunctionsUC::getVal($arrMeta, "_yoast_wpseo_primary_category");
    		
    		
    		if(empty($mainCategoryID))
    			$mainCategoryID = UniteFunctionsUC::getVal($arrMeta, "rank_math_primary_category");
    				
    		if(empty($mainCategoryID)){
    
    			unset($arrTerms["uncategorized"]);
    			$arrTermData = UniteFunctionsUC::getArrFirstValue($arrTerms);
    
    			return($arrTermData);
    		}
            
  • With:
    	/**
    	 * get post main category from the list of terms
    	 */
    	private function getPostMainCategory($arrTerms, $postID){
    
    		//get term data
    
    		if(count($arrTerms) == 1){		//single
    			$arrTermData = UniteFunctionsUC::getArrFirstValue($arrTerms);
    			return($arrTermData);
    		}
    		
    		$arrMeta = UniteFunctionsWPUC::getPostMeta($postID,true);
    		
    		$mainCategoryID = UniteFunctionsUC::getVal($arrMeta, "_yoast_wpseo_primary_category");
    		
    		
    		if(empty($mainCategoryID))
    			$mainCategoryID = UniteFunctionsUC::getVal($arrMeta, "rank_math_primary_category");
    
    		// WPML Workaround for compsupp-8023
    		if (!empty($mainCategoryID)) {
            $mainCategoryID = apply_filters('wpml_object_id', $mainCategoryID, 'category', true);
    		}
    				
    		if(empty($mainCategoryID)){
    
    			unset($arrTerms["uncategorized"]);
    			$arrTermData = UniteFunctionsUC::getArrFirstValue($arrTerms);
    
    			return($arrTermData);
    		}
            

답글 남기기

주제에 집중하고 다른 사람을 존중해 주세요. 이 게시물과 관련 없는 문제에 도움이 필요하면 지원 포럼을 사용하여 채팅을 시작하거나 티켓을 제출하세요.

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