use WooCommerce product attributes in meta description
-
Hi
I want to use WooCommerce product attributes in meta description. Just like custom fields, that can specify which custom field we want to load in meta descriptions automatically.
I found this topic but I don’t know which function of WooCommerce could handle what I want.
I wrote a code :
/** * A custom replacement variable to get the current month in custom format */ add_action( 'rank_math/vars/register_extra_replacements', function(){ rank_math_register_var_replacement( 'product_attributes', [ 'name' => esc_html__( 'Product Attributes', 'rank-math' ), 'description' => esc_html__( 'Current Product Attributes', 'rank-math' ), 'variable' => 'product_attributes', 'example' => product_attributes_callback(), ], 'product_attributes_callback()' ); }); function product_attributes_callback(){ $result = wc_attribute_label( 'pa_gender' ); return $result; }
But that just returns the label. I need value of the attribute.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘use WooCommerce product attributes in meta description’ is closed to new replies.