• Resolved GSMtricks

    (@gsmtricks)


    It would be good if you add this function.
    Example for product description:
    Product name etc. Interfaces: %attribute(interfaces)
    As a result, I will have automatic descriptions for products with attributes.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @gsmtricks,

    Thank you for contacting the support.

    We provide a filter that you can use to add custom variables:
    https://rankmath.com/kb/filters-hooks-api-developer/#add-extra-variables

    You can refer to the following code:
    https://github.com/rankmath/seo-by-rank-math/blob/master/includes/modules/woocommerce/class-wc-vars.php#L24

    With that being said, there are existing feature requests, so I’ve added your vote to our internal suggestions lists. If your suggestions are something that we’re able to introduce, I’ll be sure to let you know.

    If there’s anything else we can help you with, please let us know. We are here to assist.

    Thread Starter GSMtricks

    (@gsmtricks)

    Could you validate it?

    I have attribute: Supported by
    slug for this attribute: supported-by

    add_action( ‘rank_math/vars/register_extra_replacements’, function(){
    rank_math_register_var_replacement(
    ‘supported-by’,
    [
    ‘name’ => esc_html__( ‘Attribute: Supported by’, ‘rank-math’ ),
    ‘description’ => esc_html__( ‘Custom variable description.’, ‘rank-math’ ),
    ‘variable’ => ‘supported-by’,
    ‘example’ => ‘supported-by_callback()’,
    ],
    ‘supported-by_callback()’
    );
    });

    Plugin Support Rank Math Support

    (@rankmathteam)

    Hello @gsmtricks

    Here is the updated code:

    add_action( 'rank_math/vars/register_extra_replacements', function() {
    	rank_math_register_var_replacement(
    		'supported-by',
    		[
    			'name' => esc_html__( 'Attribute: Supported by', 'rank-math' ),
    			'description' => esc_html__( 'Custom variable description.', 'rank-math' ),
    			'variable' => 'supported-by',
    			'example' => supported_by_callback(),
    		],
    		'supported_by_callback'
    	);
    } );
    
    function supported_by_callback() {
    	// Add your code here to get the attribute value..
    	return 'Supported by value..';
    }

    Hope that helps. Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Product attributes’ is closed to new replies.