rankmath / seo-by-rank-math

Rank Math is a revolutionary WordPress SEO Plugin that combines the features of many SEO tools and lets you multiply your traffic in the easiest way possible :bulb: :chart_with_upwards_trend: →
https://rankmath.com
107 stars 52 forks source link

Wrong category hierarchy in Product Schema #60

Closed duZas closed 3 years ago

duZas commented 3 years ago

Describe the bug Wrong category hierarchy in Product Schema Actual product category structure: Parent1 > Parent2> Parent3 > currentCategory

in schema: [@type] Product ... [category] => Parent3> Parent2> Parent1 > currentCategory

Expected behavior [category] => Parent1> Parent2> Parent3 > currentCategory

Additional context There is wrong ordering in seo-by-rank-math>includes>modules>schema>snippets>class-product.php function get_category( $product_id, $taxonomy )

get_ancestors() of currentCategory retrieves parent categories in reverse order, then you add currentCategory at the end. Should be opposite.