Skip Navigation

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

Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>