Structured data – Review

#585515
  • Resolved Fdl
    Rank Math free

    Hello,

    Im going to use the schema Product for my reviews.
    How is it possible to show the positive and negatives points (negativeNotes/positiveNotes) ?

    I would like to use this method to extend the Schema from the plugin and add additional properties:
    https://rankmath.com/kb/filters-hooks-api-developer/#extend-json-ld-data

    then I should add this code in the rank-math.php File ?

    /**
    * Collect data to output in JSON-LD.
    *
    * @param array $unsigned An array of data to output in json-ld.
    * @param JsonLD $unsigned JsonLD instance.
    */
    add_filter( ‘rank_math/json_ld’, function( $data, $jsonld ) {
    return [];
    }, 99, 2);

    And after, how and where could I add the negativeNotes and positiveNotes for each review ?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    Yes, you would need to paste that in rank-math.php file in your theme’s folder.

    However, please note that you may need to edit/customize the filter further to apply the positiveNotes and negativeNotes to each of your products’ schema.

    Here’s a sample filter to target the product schema specifically and add the positiveNotes to get you started:

    add_filter( "rank_math/snippet/rich_snippet_product_entity", function( $entity ) {
      $entity['review']['positiveNotes'] = [];  
      $entity['review']['positiveNotes']['@type'] = 'ItemList';
      $entity['review']['positiveNotes']['itemListElement'][] = [
        '@type' => 'ListItem',
        'position' => 1,
        'name' => 'Useful'
      ];
     return $entity;
    });

    Hope that helps.

    Thank you.

    Fdl
    Rank Math free

    Hello,

    Thanks for your answer.

    Where exactly should I edit/customize the filter to apply the positiveNotes and negativeNotes to each of my products’ schema ?

    Hello,

    You may need to customize/edit the code itself so you can achieve the positiveNotes and negativeNotes to be applied to the product schema.

    Unfortunately, customizing the filter further is already out of our scope of support. To further customize the code, you can hire someone on Fiverr.com or any other freelancing website for them to achieve that on your website.

    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 3 replies - 1 through 3 (of 3 total)

The ticket ‘Structured data – Review’ is closed to new replies.