How to use custom fields from in SEO title from another custom post type

#451737
  • Resolved Terry Keyes
    Rank Math free

    Hi, I’m trying to setup my SEO titles using variables but I can’t seem to figure out how to use custom field data from another custom post type. As an example, I have a custom post type called ‘business info’ which has a field called ‘city’. When I use the field name in the variable %customfield(city)% it does not work on my normal pages. I’m sure it’s something simple I’m overlooking but I could not find anything in the knowledgebase.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thank you for contacting Rank Math support, and sorry for any inconvenience that might have been caused due to that.

    This wouldn’t work as the %customfield(...)% variable can only extract the data from where the custom field is currently initiated so the variable will only work on “business info” CPT.

    If you wish to retrieve the field from another post type, you may need to use get_field function instead and attach it to a custom variable which you may refer to in this guide: https://rankmath.com/kb/variables-in-seo-title-description/#how-to-add-custom-variables

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Thank you for your response. I am still unclear how to accomplish this from the given information. I could not find the get_field function in the linked article. If you could please provide steps on how to do this I would greatly appreciate it!

    Nigel
    Rank Math business

    Hello,

    get_field is an ACF function you can refer to this article for more information about it: https://www.advancedcustomfields.com/resources/get_field/

    You can refer to the following guide for how to add custom variables to Rank Math: https://rankmath.com/kb/variables-in-seo-title-description/#how-to-add-custom-variables

    Hope that helps. Please let us know if you have 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.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘How to use custom fields from in SEO title from another custom post type’ is closed to new replies.