add_filter( 'rank_math/vars/register_extra_replacements', function( $replacements ) { $replacements['acf_lead'] = function() { $post_id = get_queried_object_id(); if ( ! $post_id ) return ''; if ( function_exists('get_field') ) { $val = get_field( 'lead', $post_id ); if ( is_string( $val ) && $val !== '' ) return $val; } return (string) get_post_meta( $post_id, 'lead', true ); }; return $replacements; }, 10, 1 );