-
I am trying to fetch the default page title for a given post in a custom graphql field (https://www.wpgraphql.com/2020/03/11/registering-graphql-fields-with-arguments/). I have found these two examples:
– https://support.rankmath.com/ticket/getting-the-rendered-meta-title-value-in-php/
– https://support.rankmath.com/ticket/code-to-use-meta-title-in-php-markup/However, none of them work.
RankMath\Helper::get_settings( "titles.pt_{$post->post_type}_title" ) // returns: "%title% %sep% %sitename%"
RankMath\Helper::replace_vars( $title, $post ) // returns: " " (string with one space in it)
RankMath\Paper\Paper::get()->get_title() // returns "" (empty string)
It seems as though none of the replace_wars settings work in GraphQL / WP-JSON. Is there some hook/filter I need to activate beforehand?
The ticket ‘Get page title in WP GraphQL / Rest API’ is closed to new replies.