mbcreation

// Maillage interne page produit

Apr 27th, 2022
798
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. // Maillage interne page produit
  2.  
  3. $maillage = [
  4.    
  5.     'ancre 1' => 'https://link',
  6.     'ancre 2' => 'https://link',
  7.     'ancre 3' => 'https://link',
  8.     'ancre 4' => 'https://link'
  9.  
  10. ];
  11.  
  12. add_filter('woocommerce_short_description', function($desc) use ($maillage){
  13.  
  14.     if( is_product() ){
  15.  
  16.         foreach ($maillage as $word => $link) {
  17.                
  18.             if( strpos($desc, $word) !== false )
  19.                 return str_replace($word,'<a href="'.$link.'">'.$word.'</a>', $desc);
  20.  
  21.         }
  22.  
  23.     }
  24.  
  25.     return $desc;
  26.  
  27. });
Advertisement
Add Comment
Please, Sign In to add comment