How to use ACF field as Brand and Gtin

#27176
  • Resolved Felipe
    Rank Math free

    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.

    ​​​​​​

    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 ‘How to use ACF field as Brand and Gtin’ is closed to new replies.