-
Hi there,
Really hoping you can help with this. To preface, I am not very proficient in programming so forgive me if my attempt looks poor.
I have an ACF field that I named “your_reward”. The field type is a text field. I am trying to make it so all my posts display the information in this field by default in RankMaths single post title.
I tried following your steps at this link and ended up with the following code:
/**
* Action: 'rank_math/vars/register_extra_replacements' - Allows adding extra variables.
*/add_action( 'rank_math/vars/register_extra_replacements', function(){
rank_math_register_var_replacement(
'your_reward',
[
'name' => esc_html__( 'Your Reward.', 'rank-math' ),
'description' => esc_html__( 'Shows Reward For Current Post.', 'rank-math' ),
'variable' => 'your_reward',
'example' => 'your_reward()',
],
'your_reward()'
);
});
Whilst this is showing the variable in the dropdown menu, it’s not pulling the data from the ACF field, so I’m doing something wrong. I’d imagine the solution is rather obvious, but due to my limited knowledge I’m not able to figure it out.
I’d really appreciate your help.
Many thanks,
Tom
The ticket ‘Using ACF Field in schema’ is closed to new replies.