-
Hi,
I have this function in rank-math.php to change the seo title on some of my posts :
/** * Filter to change the page title. * * @param string $title */ add_filter( 'rank_math/frontend/title', function( $title ) { $categories = array_map( function ( $category ) { return $category->slug; }, get_the_category() ); if (count($categories) > 0) { // Add content to page title for specific post categories if ( in_array( 'temoignage', $categories ) ) { $post = get_post(); // Cannot find function to get a custom field ? $job = RankMath\Post::get_meta('job', $post->ID, ''); $text = 'Témoignage %title% '.$job.' %sep% %sitename%'; $title = RankMath\Helper::replace_vars($text , $post ); } } return $title; });I have a custom field “job” in all of these posts, is it possible to access it in the code above ? I cannot seem to find any documentation on all of the available functions for “RankMath\Helper”, “RankMath\Post”, etc.
Thank you very much for your time
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The ticket ‘Get custom field from a post in rank-math.php’ is closed to new replies.