Hello,
We apologize for the issue you are facing with the variables not pulling the required data in Rank Math. Thank you for raising this concern.
To troubleshoot this issue, please ensure that you have correctly implemented the variables in your theme’s rank-math.php
file. Here’s a brief overview of how to register a custom variable:
-
Add Code Snippet: In the Theme File Editor, choose the rank-math.php
file and add the following code snippet:
add_action('rank_math/vars/register_extra_replacements', function () {
rank_math_register_var_replacement(
'job_location',
array(
'name' => esc_html__('Job Location', 'rank-math'),
'description' => esc_html__('The location of the job.', 'rank-math'),
'variable' => 'job_location',
'example' => 'job_location_callback()',
),
'job_location_callback'
);
});
function job_location_callback() {
// Your logic to retrieve job location data
return get_post_meta(get_the_ID(), 'job_location', true);
}
Make sure to replace the logic in job_location_callback()
with the appropriate method to retrieve your job location data.
-
Update the File: After adding the code snippet, click the Update File button to save your changes.
-
Use Variables: You can then use this variable in your Titles & Meta settings or within your content as needed.
If you have followed these steps and are still experiencing issues, please reply to this ticket, and a human agent from the Rank Math Support team will take over and assist you further.
Thank you for your patience, and we look forward to helping you resolve this matter!
Sources:
Using Variables in the SEO Title and Description » Rank Math
Hello,
Thank you for contacting Rank Math support.
Please share the filters you have used to create custom variables so we can check and assist you further. You can also share screenshots of the custom fields where you are adding the data in the job posts using a tool like https://imgur.com/.
Looking forward to helping you.
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.