Hello,
Thank you for contacting Rank Math today.
The selection of what goes into the related products is really something that is handled by WooCommerce or your theme depending on what features it has.
Rank Math does not really have a specific feature for this.
You might need to do your own modifications on your own to get this working as you want.
Having said that, here’s an example code of how you can extract the primary category from a product to update the code you mentioned in the sensitive data section:
$primary_cat_id = get_post_meta( $product->id, 'rank_math_primary_category', true );
Hope this helps find a solution for your request.
Don’t hesitate to get in touch if you have any other questions.
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.