Variable Replacement Callback Function Error

#56238
  • Resolved Anonymous
    Rank Math free

    When doing the following…

    /**
    * 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’;
    }

    The following error appears on the front end CPT where I used the variable.

    Warning: call_user_func() expects parameter 1 to be a valid callback, function ‘get_ait_item_address()’ not found or invalid function name in C:\Users\richa\Local Sites\directorypro\app\public\wp-content\plugins\seo-by-rank-math\includes\replace-variables\class-variable.php…

    • This topic was modified 5 years ago by .
Viewing 3 replies - 1 through 3 (of 3 total)
  • Anonymous
    Rank Math free

    BTW, it shows up fine in the drop down lists, and is being replaced on my custom post type admin screen. It just doesn’t work on the front end.

    Anonymous
    Rank Math free

    Found my error. The call back function does not require () when called from the registration funciton.

    Michael Davis
    Rank Math pro

    Hello,

    Thank you for contacting Rank math.

    We are glad you were able to resolve your issue.

    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)

The ticket ‘Variable Replacement Callback Function Error’ is closed to new replies.