Brand for WooCommerce Products

#281700
  • Resolved Patrick
    Rank Math free

    Hello, I tested your code to add the brand but it does not work

    /**
    * Filter to add custom Brand for WooCommerce Products.
    */
    add_filter(‘rank_math/snippet/rich_snippet_product_entity’, function( $entity ) {
    $entity[‘brand’] = ‘Rank Math’;
    return $entity;
    }
    );

Viewing 11 replies - 16 through 26 (of 26 total)
  • code works well for gtin and rating
    but for the brand it but Brand as a brand
    and if I change Brand by my brand its bug

    add_filter( ‘rank_math/snippet/rich_snippet_product_entity’, function( $entity ) {
    global $product;
    if ( isset( $entity[‘aggregateRating’] ) ) {
    if ( $entity[‘aggregateRating’][‘ratingValue’] > 5 || $entity[‘aggregateRating’][‘ratingValue’] <= 1 ) {
    $entity[‘aggregateRating’][‘ratingValue’] = 5;
    }
    }
    $brand = $product->get_attribute(‘pa_brand’);
    $brands = explode( ‘,’, $brand );
    if ( ! empty( $brands ) ) {
    $brand = $brands[0];
    }else{
    $brand = ‘French Baskets’;
    }
    $entity[‘brand’] = array(
    ‘@type’ => ‘Brand’,
    ‘name’ => $brand,
    );
    // We use product Gtin codebar as our sku. No need to add another field, just fill from there
    $entity[‘gtin13’] = $product->get_sku();
    return $entity;
    }

    );

    code works well for gtin and rating
    but for the brand it but Brand as a brand
    and if I change Brand by my brand its bug

    Hello,

    If you want to use custom value for your brand then select the Custom option from the drop-down list.

    custom-brand

    Once you select Custom you’ll be able to add a Brand value that you want to use.

    Please follow the article to set your custom brand:
    https://rankmath.com/kb/woocommerce-custom-brand-schema/

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Thank you.

    I just want a brand of mine on all products
    I am not the custom option

    I am not the custom option

    I turn around
    zero rapunzel survey
    I’m looking for a personal code that doesn’t really respond
    it’s a shame your module and really well done and I almost bought it

    code

    why can’t we change the Brand name to the name of its brand?
    in the tests we see Brand = Brand

    Thank you I found the solution on google

    Hello,

    I can check that the Brand property is being added to your products and your product Schema is not showing any warning for brand property in the Rich Results Test:

    Please check and let us know if you need any other assistance.

    Thanks.

    yes the right code and if you had to change two little words
    but many search on google today good day

    add_filter( ‘rank_math/snippet/rich_snippet_product_entity’, function( $entity ) {
    global $product;
    if ( isset( $entity[‘aggregateRating’] ) ) {
    if ( $entity[‘aggregateRating’][‘ratingValue’] > 5 || $entity[‘aggregateRating’][‘ratingValue’] <= 1 ) {
    $entity[‘aggregateRating’][‘ratingValue’] = 5;
    }
    }
    $brand = $product->get_attribute(‘pa_brand’);
    $brands = explode( ‘,’, $brand );
    if ( ! empty( $brands ) ) {
    $brand = $brands[0];
    }else{
    $brand = ‘French Baskets’;
    }
    $entity[‘brand’] = array(
    ‘@type’ => ‘Brand’,
    ‘name’ => ‘French Baskets’,
    );
    // We use product Gtin codebar as our sku. No need to add another field, just fill from there
    $entity[‘gtin13’] = $product->get_sku();
    return $entity;
    }

    );

    Hello,

    We are glad that you were able to resolve the issue.

    Please feel free to reach out to us again in case you need any other assistance.

    We are here to help.

    Thank you.

Viewing 11 replies - 16 through 26 (of 26 total)

The ticket ‘Brand for WooCommerce Products’ is closed to new replies.