Variable Replacement Callback Function Error

#56238
  • Resolved Richard Aubin
    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 3 years, 10 months ago by Richard Aubin.
Viewing 3 replies - 1 through 3 (of 3 total)
  • 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.

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

    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.