Brand name and tag in product title

#6055
  • Resolved Mathieu Nicol
    Rank Math free

    Hi,

    I’m trying to add %wc_brand% or %tag% variable in product SEO title but it doesn t work.

    Could help me to resolve this problem?

    thanks

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    Rank Math does not currently have a replacement variable for the product tag, using the post %tag% variable will not work on the product page. You will need to register a new replacement variable to be able to use this value on the post title.

    If you have a brand value set on your product attributes, you can make use of the following code on your functions.php file to load the %wc_brand% :

    /**
     * Filter to show brand value in snippet preview.
     */
    add_filter( 'rank_math/vars/replacements', function( $vars ) {
        global $product;
     
        if(!$product){
            return $vars;
        }
     
        if(isset($vars['wc_brand'])){
            $brand = $product->get_attribute('brand');
           
            $vars['%wc_brand%']['example'] = $brand;
        }
     
      return $vars;
    });

    I hope this info helps. Thank you.

    ​​​​​​​

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 1 replies (of 1 total)

The ticket ‘Brand name and tag in product title’ is closed to new replies.