• Resolved alexsina

    (@alexsina)


    Hello,

    We are using the following code snippets for MPN and priceValidUntil

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
    	global $product;
    	if ( ! is_a( $product, 'WC_Product' ) ) {
    		return $entity;
    	}
    	{
    		$entity['offers'][ 'priceValidUntil' ] = date( 'Y-12-31' );
    	}
    	$entity['mpn'] = "{$product->get_sku()}";
    	return $entity;
    } );
    
    /**
     * Filter to add Brand Name for Products.
     *
     * @param array $entity Snippet Data
     * @return array
     */
    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
        $entity['brand'] = 'our brand';
        return $entity;
    });

    I just noted that there are some update:

    Improved: The priceValidUntil property. By default, the Product schema will show the date +1 year from the current year

    So, are these code snippets lines still working with Rankmath’s latest version please?

    If not, would you please update the code lines only for MPN and Brand?

    Thanks, and have a nice day.

Viewing 1 replies (of 1 total)
  • Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @alexsina,

    Thank you for contacting the support.

    The priceValidUntilproperty is not needed since we add a default value in our plugin.

    Here is the updated code with only mpn & brand value:

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
    	global $product;
    	if ( ! is_a( $product, 'WC_Product' ) ) {
    		return $entity;
    	}
    
    	$entity['mpn'] = "{$product->get_sku()}";
    	$entity['brand'] = 'our brand';
    	return $entity;
    } );

    Hope that helps.

Viewing 1 replies (of 1 total)
  • The topic ‘MPN and priceValidUntil’ is closed to new replies.