-
From Rank Math Snippet Editor we can add any taxonomy like %title% %sep% from drop down menu,
but i want to use a custom variable like %spec% , which will show the value as “Full phone specifications” in my title.
I mean now if i select %title% %sep% that time i can see in my Title Box “Apple iPhone 13 Pro – “..SO i want to create a custom variable like %spec%, so when i will select %spec% from drop-down menu after %title% %sep%, that time we can see %title% %sep% %spec% and Value will show “Apple iPhone 13 Pro – Full phone specifications”So for creating this custom taxonomy i found a code in your support blog and i tried to modified it for me, i am given the code below which i modified but i am not sure its right or wrong, because i am not expert in coding…
COuld you please check that my code is right or something wrong??// Custom variable for the custom field from the wp_postmeta table
add_action( ‘rank_math/vars/register_extra_replacements’, function(){
rank_math_register_var_replacement(
‘spec’,
[
‘name’ => esc_html__( ‘Mobile Specification’, ‘rank-math’ ),
‘description’ => esc_html__( ‘Full phone specifications’, ‘rank-math’ ),
‘variable’ => ‘spec’,
‘example’ => ‘Full phone specifications’,
],
‘phone_spec_callback’
);
});
function phone_spec_callback() {
return get_post_meta(get_queried_object_id(), ‘_spec’, true);
}
The ticket ‘I want to add a custom name in my post title by using a variable’ is closed to new replies.