How to use ACF field as Brand and Gtin

  • I know that I can choose attributes as Brand name
    But I need to use a ACF field for that
    and the same for the Gtin number

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math today.

    You can use a filter to modify the schema data. Here is an example of how the code would look like:

    /**
     * Filter to Short-circuit Schema if a 3rd party is interested in generating their own data.
     * Replace $schmea_type with schema name like article, review, etc.
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( "rank_math/snippet/rich_snippet_product_entity", function( $entity ) {
    	global $product;
    	$id = $product->get_id();
    	$entity['brand'] = get_field('field_name',$id);
    	$entity['gtin8'] = get_field('field_name',$id);
     return $entity;
    });

    Looking forward to helping you. Thank you.

    ​​​​​​

Viewing 1 replies (of 1 total)

You must be logged in to reply to this ticket.