Product Meta Descriptions

#458574
  • Resolved Melanie Smit
    Rank Math free

    Do you have the option to use Product content or Product Descriptions as the Woocommerce Single Product Description meta in the premium version? I see the free version only has product short description as an option.

Viewing 1 replies (of 1 total)
  • Nigel
    Rank Math business

    Hello,

    Thank you for contacting Rank Math for help with setting WooCommerce product descriptions as the product meta description.

    You will have to create a custom variable for the product description. This works in both the free and PRO versins of Rank Math. To do that you will have to add the following code snippet to your website:

    
    add_action( 'rank_math/vars/register_extra_replacements', function() {
    	rank_math_register_var_replacement(
    		'woo_full_desc',
    		[
    			'name'        => esc_html__( 'Woo Full Desc.', 'rank-math' ),
    			'description' => esc_html__( 'Woo Full Description...', 'rank-math' ),
    			'variable'    => 'woo_full_desc',
    			'example'     => woo_full_desc_callback(),
    		],
    		'woo_full_desc_callback'
    	);
    } );
    function woo_full_desc_callback() {
    	global $post;
    	if ( empty( $post ) ) {
    		return 'Product Description';
    	}
    
    	return wp_strip_all_tags( $post->post_content );
    }
    

    You can follow this guide for how to add the code to your website: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps. Please let us know if you have 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.

Viewing 1 replies (of 1 total)

The ticket ‘Product Meta Descriptions’ is closed to new replies.