/** * Use the Description from Global Setting, if the description is missing in the Post metabox */ add_action( 'rank_math/frontend/description', function( $description ) { global $post; $desc = RankMath\Post::get_meta( 'description', $post->ID ); if ( is_product()) { $desc = RankMath\Helper::get_settings( "titles.pt_{$post->post_type}_description" ); if ( $desc ) { return RankMath\Helper::replace_vars( $desc, $post ); } } return $description; });