-
On a taxonomy page, I collect a couple of basic pieces of ACF text field data (event_date, event_price). I would like to use this data in the RM meta title and description.
It seems the knowledge base is missing this basic instructional guide. I can only find info on using ACF in JSON schema or ACF repeaters.
Will you please demonstrate to me/us the code needed in functions.php file, and how to call the ACF text field data within the RM meta snippet?
Thank you!
-
Hello,
Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.
You can use the following variable to add the data from an ACF field to the page title and description:
%customfield(field-name)%Here’s a link for more information:
https://rankmath.com/kb/variables-in-seo-title-description/#num-39-custom-field-advancedHope that helps.
Thank you.
It says in your own documentation this is incorrect. “The custom field variable (%customfield%) will not work on the ACF fields. This is due to how ACF stores values in the post-meta table. It stores values in a serialized format for groups, and for other fields, it stores key-value pairs.
Also, any attempts to use %customfield% in a snippet on my end fail. I cannot paste it, or select it from the dropdown. Is it a Pro feature only?
Hello,
Yes, the variable
%customfield(...)%will not work if the value from the custom field is serialized. However, the variable should still work if the custom field is returning a valid value such as a string.If you indeed have a serialized value from a custom field, you may need to create a custom variable to display the processed data from that custom field. Use the
get_fieldfunction and attach it to a custom variable. Here is the reference guide on how to add custom variables:
https://rankmath.com/kb/variables-in-seo-title-description/#how-to-add-custom-variablesThe variable
%customfield(...)%is available in the Free version so it should work on your end. Can you please try recording a video screencast from your end showing the issue? You may use this handy tool https://loom.com/.Looking forward to helping you.
Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Hello,
It seems to be working fine on our end:
https://i.rankmath.com/v/6CqprcAssuming you are using the latest version of all the plugins and the themes (please update if not yet), it would seem like a conflict with one of the plugins or the theme you are using.
To determine that, please follow this troubleshooting guide:
https://rankmath.com/kb/check-plugin-conflicts/Here is a video you can follow as well:
Only the site admin would know and your users won’t be affected by this troubleshooting.
If the issue persists, please record a video screencast using a tool like Loom showing the troubleshooting and edit the first post on this ticket and include your WordPress & FTP logins in the designated Sensitive Data section.
Please do take a complete backup of your website before sharing the information with us.
It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:
https://wordpress.org/plugins/temporary-login-without-password/
You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):
https://wordpress.org/plugins/wp-security-audit-log/
Please do take a complete backup of your website before sharing the information with us.
We really look forward to helping you.
Hello,
I have updated the sensitive data as requested. Can you please check further?
I have run the troubleshooting. I can confirm it is not any plugin conflict. It must be conflicting with my theme. But it does work on all posts, pages, and custom post types. It only fails to work on taxonomies. See the screenshot attached in the sensitive data area.
I have also searched through all theme files for use of “field-name” or “customfield” for potential naming conflict and I have none.
Any further suggestion on potential areas or conflicts that would cause it to fail only on taxonomies?
Thank you.
Hello,
Sorry for the confusion. The customfield variable only works on the post types, not on the taxonomies. For taxonomies, you will have to create a custom variable. Here is an example to create a custom variable named
%seo_title_slug%for a field namedseo_title:add_action('rank_math/vars/register_extra_replacements', function () { rank_math_register_var_replacement( 'seo_title_slug', array( 'name' => esc_html__('SEO Tilte', 'rank-math'), 'description' => esc_html__('Seo Title of the Affiliate Store', 'rank-math'), 'variable' => 'seo_title_slug', 'example' => 'seo_title_callback()', ), 'seo_title_callback' ); }); function seo_title_callback() { return get_term_meta(get_queried_object_id(), 'seo_title', true); }You can modify and create a variable for your custom fields. Here is how to add a filter to your site: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Hope that helps. Let us know if you need any other assistance.
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.
The ticket ‘How to use basic ACF text fields in RM snippet?’ is closed to new replies.