Pular para o conteúdo Pular para a barra lateral

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

Deixe uma resposta

Por favor, mantenha-se no tópico e seja respeitoso com os outros. Se precisar de ajuda com questões não relacionadas a este post, use nosso Fórum de Suporte para iniciar um chat ou enviar um ticket.

Você pode usar estas tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>