• Resolved Bobkata

    (@bobkata)


    Hello I use this snippet with WCFM to get store name for brand on schema.org
    The problem is that in schema markup test tool it says the type is “thing” (invalid object type for field brand) Can I do something about it.
    Thank you for this great plugin I use it for short time but starting loving it.

    // Use vendor store name for brand if using RankMath SEO.
    add_filter( ‘rank_math/snippet/rich_snippet_product_entity’, function( $entity ) {
    global $post;
    if(wcfm_is_vendor($post->post_author)) {
    $vendor_id = apply_filters(‘wcfm_current_vendor_id’, $post->post_author);
    $shop_name = wcfm_get_vendor_store_name( $vendor_id );
    $entity[‘brand’] = $shop_name;
    }
    return $entity;
    });

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

    (@rankmathteam)

    Hello @bobkata,

    Thank you for contacting the support.

    You’re adding the $shop_name variable’s value directly to the brand entity when the entity itself is not defined.

    Please try using this filter instead and see if it fixes the issue:

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
    if(wcfm_is_vendor($post->post_author)) {
    $vendor_id = apply_filters('wcfm_current_vendor_id', $post->post_author);
    $shop_name = wcfm_get_vendor_store_name( $vendor_id );
    $entity['brand']['@type'] = 'Brand';
    $entity['brand']['name'] = $shop_name;
    }
    return $entity;
    });

    Let us know how that goes.

    Thread Starter Bobkata

    (@bobkata)

    No, unfortunately it’s not working it tells missing field brand when testing for reach snippet

    Thread Starter Bobkata

    (@bobkata)

    It’s seems you miss (global $post;) part of the snippet now is working ?? thank you very much.
    Here is right one.

    add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
    	global $post;
    if(wcfm_is_vendor($post->post_author)) {
    $vendor_id = apply_filters('wcfm_current_vendor_id', $post->post_author);
    $shop_name = wcfm_get_vendor_store_name( $vendor_id );
    $entity['brand']['@type'] = 'Brand';
    $entity['brand']['name'] = $shop_name;
    }
    return $entity;
    });
    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @bobkata,

    Sorry for that. We are glad that you were able to identify the mistake in the filter we provided and make it work to fix the issue on your site.

    Please don’t hesitate to get in touch in case you need any other assistance.

    We are here to help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Schema brand’ is closed to new replies.