Chuyển đến nội dung Chuyển đến thanh bên

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);
    		}
            

Để lại trả lời

Vui lòng giữ đúng chủ đề và tôn trọng người khác. Nếu bạn cần trợ giúp với các vấn đề không liên quan đến bài đăng này, hãy sử dụng Diễn đàn Hỗ trợ của chúng tôi để bắt đầu trò chuyện hoặc gửi vé hỗ trợ.

Bạn có thể sử dụng các thẻ này:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>