Any hooks for adding custom variables in Title Tag Box

#45931
  • Resolved Dale
    Rank Math free

    I had a look around and could not find.

    Need to be able to make my own variable for the title tag box.

    For example one exists already called %title%

    Is there a hook I can tap into to make my %ownVariable% for the title tag/meta description box?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Alberto
    Rank Math business

    Hello Dale,

    Thanks for getting in touch with us.

    You can use this filter to register your own variable and show it in the drop-down at WordPress Dashboard > Rank Math > Titles & Meta >

    /**
     * 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(
     'custom_variable_slug',
     [
     'name'        => esc_html__( 'Custom variable name.', 'rank-math' ),
     'description' => esc_html__( 'Custom variable description.', 'rank-math' ),
     'variable'    => 'custom_variable_slug',
     'example'     => 'custom_variable_callback()',
     ],
     'custom_variable_callback()'
     );
    });

    We are assuming you know a bit of PHP to make it work.

    If not, please let us know so our team can help you further.

    Thank you.

    Dale
    Rank Math free

    Yes thank you I can work with this.

    Alberto
    Rank Math business

    Hello Dale,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do 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 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this ticket.