Hello,
We apologize for the issue you are facing with loading the ACF text field in your SEO description. The behavior you’re experiencing is likely due to how Rank Math processes custom fields in templates versus individual posts.
When using the variable %customfield(kratky_popis)%
in a global template, it may not be able to retrieve the value because the context of the current post is not set correctly. In contrast, when you use it directly in an individual post, Rank Math can access the specific post’s data, which is why it works there.
To resolve this issue, you might consider using a filter to ensure that the correct post context is available when generating the SEO description in your template. You can define a new variable using the appropriate filter to get the value from the ACF field and use it in your template.
Here’s a general approach:
- Use the
rank_math/json_ld
filter to add your custom field value to the JSON-LD data.
- Ensure that your template is correctly set up to reference the current post’s data.
If you need further assistance with implementing this, please reply to this ticket, and a human agent from the Rank Math Support team will be happy to help you out.
Thank you for raising this concern!
Sources:
How to Integrate Rank Math With Advanced Custom Fields » Rank Math
Hello,
Thank you for contacting support.
There shouldn’t be a difference in using the variables in the global settings or the page settings. The only thing you need to be sure of is that the single pages don’t have any custom data in the meta description already, otherwise, that would override the global settings.
You can override that behavior with the following filter:
add_action( 'rank_math/frontend/description', function( $description ) {
global $post;
if( $post ) {
$global_description = RankMath\Helper::get_settings( "titles.pt_{$post->post_type}_description" );
$description = RankMath\Helper::replace_vars( $global_description, $post );
}
return $description;
});
Please note that since you are using a custom post type you might need to add some additional conditions on the filter if you are looking to only do this for the properties on the website.
Don’t hesitate to get in touch if you have any other 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.