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

Laisser une réponse

Veuillez rester dans le sujet et être respectueux envers les autres. Si vous avez besoin d'aide pour des problèmes non liés à ce message, utilisez notre Forum de support pour commencer une discussion ou soumettre un ticket.

Vous pouvez utiliser ces balises :
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>