-
Hi i added this to my functions.php
/** * Filter to add custom variables */ add_filter( 'rank_math/vars/replacements', function( $vars ) { global $product; if ( ! $product ) { return $vars; } // Product Category $vars['product_category'] = [ 'name' => 'Product\'s Category', 'desc' => 'Current Product Category', 'example' => wp_get_post_terms( $_GET['post'], 'product_cat', array( 'fields' => 'names', 'number' => 1 ) )[0], ]; return $vars; });
I added %product_cat% in Meta tag of product and it doesnt work
I want to add at Titles & Metas the variable product category
Product Example title: Buy %title% – %product_category% – %sitename% => ( Buy MEGA Shoes Blue – Men Shoes – Shoesshop.com)
Product Meta example: Buy online %title%. See more products for %product_category% at sale => ( Buy online %title%. See more products for Men Shoes at sale)How to achieve this?
Please add more variable, Yoast plugin had them and they are really useful
Regards
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The ticket ‘%product_category%’ is closed to new replies.