How to display Custom Template Name for customization in SEO TITLES & META

#85983
  • Resolved Puneet
    Rank Math free

    Hi,
    How to display Custom Template (Post) Name for customization in SEO TITLES & META > Post Section. For example if my custom post template name is created as custompost.php and template name is Custompost then how to call custom post under rank math SEO TITLES & META section.

    Check Image – https://ibb.co/HX1f0Ym

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    Thank you for contacting Rank Math today.

    To do that you will need to customize the following filter:

    
    /**
     * 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()'
     );
    });

    If you are not a developer, you might have to hire one to help you customize this then add it to your active theme functions.php

    Looking forward to helping you. Thank you.

    ​​​​​​

    Puneet
    Rank Math free

    Can you please clearfy which part of this code to be customised?

    My template name is Demo and create as demo.php in theme module. It would be a great pleasure if you provide code because I don’t have any web developer.

    Hello,

    I am sorry but we don’t offer code/filter customization given our small team. You wll have to hire a developer to assist you. Here is a sample implementation for reference, used to get item address:

    
    /**
    * 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(
    ‘ait_item_address’,
    [
    ‘name’ => esc_html__( ‘Ait Item Address.’, ‘rank-math’ ),
    ‘description’ => esc_html__( ‘Custom variable description.’, ‘rank-math’ ),
    ‘variable’ => ‘ait_item_address’,
    ‘example’ => get_ait_item_address(),
    ],
    ‘get_ait_item_address()’
    );
    });
    
    function get_ait_item_address(){
    return ‘address’;
    }
    

    Hope that helps. If you have any further question(s), please let us know. Thank you.

    Puneet
    Rank Math free

    Okay,
    Please add PHP Comments in code to understand code. Thank You

    Hello,

    Here is the commented 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(
    ‘ait_item_address’, //variable to add
    [
    ‘name’ => esc_html__( ‘Ait Item Address.’, ‘rank-math’ ), //variable name
    ‘description’ => esc_html__( ‘Custom variable description.’, ‘rank-math’ ), //variabledescription
    ‘variable’ => ‘ait_item_address’, //variable itself
    ‘example’ => get_ait_item_address(), //default value or placeholder
    ],
    ‘get_ait_item_address()’ //callback function
    );
    });
    
    /* define you callback function, how and where to get the variable data*/
    function get_ait_item_address(){
    return ‘address’;
    }
    

    Hope that helps. If you have any further question(s), please let us know. Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)

The ticket ‘How to display Custom Template Name for customization in SEO TITLES & META’ is closed to new replies.