How to call RM Snippet Meta Title and Description in PHP

#505969
  • Resolved Mc
    Rank Math free

    I am testing migration from Yoast.

    I have a taxonomy “stores” & custom post type “events”

    I would like to insert the RM snippet Meta Title and description values into the child theme PHP if they are not empty. I’ve done similar in Yoast similarly like this:

    $YoastTitle = YoastSEO()->meta->for_current_page()->title;
    if(!empty($YoastTitle)) {echo $YoastTitle;} else {echo $term->name;}

    Is it possible to do the same with Rank Math? If so, how?

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

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

    The data for the meta description and title are either taken from the global settings or from the postmeta table if they are added to a specific page individually.

    You can check for the presence of the postmeta keys rank_math_title and rank_math_description and if they are not present you can add them as you wish.

    ​​​​​​​Hope this helps clarify your doubts.

    Don’t hesitate to get in touch if you have any other questions.

    Mc
    Rank Math free

    Thank you for the reply. The support here seems to be quite helpful and a good reason to switch from Yoast.

    Will you please elaborate with the PHP code example(s) of the methods you mentioned above? I can read the code better than I can write.

    Thank you 😀

    Mc
    Rank Math free

    I found the right direction here in the answer that details shortcodes for both taxonomies and posts: https://support.rankmath.com/reply/470726/ 🙏

    Hello,

    We are super happy that your issue has been addressed by that thread.

    If you have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

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

You must be logged in to reply to this ticket.