Hello,
I apologize for the issue you are facing. To add a new Schema for LocalBusiness
specifically for an ExerciseGym
using ACF in your theme’s rank-math.php
file, you can follow these steps:
-
Navigate to the Theme File Editor:
- For a Classic Theme: Go to WordPress Dashboard → Appearance → Theme File Editor.
- For a Block Theme (like Divi): Go to WordPress Dashboard → Tools → Theme File Editor.


-
Select the rank-math.php
file:
- Find and select the
rank-math.php
file from the list of theme files.

-
Add the following code snippet to register the LocalBusiness
schema for an ExerciseGym
:
add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
if ( ! have_rows('gym_acf_fields') ) {
return $data;
}
$data['@context'] = 'https://rankmath.com/kb/filters-hooks-api-developer/#add-extra-variables';
$data['@type'] = 'ExerciseGym';
$data['name'] = esc_attr( get_field('gym_name') );
$data['address'] = [
'@type' => 'PostalAddress',
'streetAddress' => esc_attr( get_field('gym_street_address') ),
'addressLocality' => esc_attr( get_field('gym_city') ),
'addressRegion' => esc_attr( get_field('gym_state') ),
'postalCode' => esc_attr( get_field('gym_postal_code') ),
'addressCountry' => esc_attr( get_field('gym_country') ),
];
// Add more fields as necessary
return $data;
}, 10, 2 );
Make sure to replace 'gym_acf_fields'
, 'gym_name'
, 'gym_street_address'
, etc., with the actual field names you have set up in ACF.
-
Update the File: After adding the code, click the Update File button to save your changes.
This will help you generate the LocalBusiness schema for your ExerciseGym using ACF fields. If you have any further questions or need assistance, feel free to reply to this ticket, and a human agent from the Rank Math Support team will assist you further!
Sources:
How to Use ACF Repeater Fields to Automate FAQ Schema » Rank Math
How to Use ACF Fields in Schema Generator » Rank Math
This is an automated reply from Rank Math Support Bot. If you need further assistance, please reply to this topic and a human support agent will reply to you shortly.
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.