Page ID in title of ACF relation fields in CPT instead of page title

#818459
  • Resolved bb
    Rank Math free

    Hi!

    I use a custom post type (CPT) = Patient stories. The CPT has ACF relation fields = story_clinic and story_doctor. The relations are to two other CPTs for clinics and doctors.

    In the Rank Math Title & Meta I set the CPT title to: Story from Dr %customfield(story_doctor)% at %customfield(story_clinic)%.

    Instead of getting a title for the Patient stories CPT like “Story from Dr Ericssen at New York Hernia Clinic” I get “Story from Dr 1456 at 1555.

    1456 is the page id for Dr Ericssens CPT and 1555 is for New Yorj Hernia Clinics CPT

    Is there a way of solving this?

    With best regards,

    b

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

    Thank you for reaching out to us with your concern about displaying the Page ID instead of the Page Title in the Rank Math Title & Meta for your custom post type "Patient stories" with ACF relation fields.

    To display the actual Page Title instead of the Page ID in the Rank Math Title & Meta, you can use the %title% variable. This variable will dynamically fetch and display the title of the related page instead of the ID.

    You can update your Rank Math Title & Meta settings for the Patient stories CPT to: "Story from Dr %customfield(story_doctor: title)% at %customfield(story_clinic: title)%."

    By using %customfield(story_doctor: title)% and %customfield(story_clinic: title)%, Rank Math will fetch and display the actual titles of the related pages instead of their IDs.

    Please make this adjustment in your Rank Math settings, and it should resolve the issue you are facing with displaying the Page Titles correctly.

    If you need further assistance or have any other questions, feel free to let us know.

    Best regards,

    Sources:
    Using Variables in the SEO Title and Description ยป Rank Math
    How to Integrate Rank Math With Advanced Custom Fields ยป Rank Math
    How to Fix "Either ‘name’ or ‘item.name’ should be specified" Error ยป Rank Math
    How to Use ACF Fields in Schema Generator ยป Rank Math

    bb
    Rank Math free

    I’ve tried adding the :title part to the custom field variable as described but instead of displaying the title is displays nothing…

    Hello,

    Thank you for your query and we are so sorry about the trouble this must have caused.

    What happens here is that your custom fields allow you to choose a specific post from another post type and save the post_id as the identifier. Now, when Rank Math queries those custom fields, it retrieves the identifier which is the post_id.

    In this case, you’ll have to create a custom variable that queries the information from the specific post using the post_id.

    Here’s how you can create a custom variable: 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 my assistance with anything else.

    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 ‘Page ID in title of ACF relation fields in CPT instead of page title’ is closed to new replies.