error with code

#426641
  • Resolved Sebasweb
    Rank Math free

    Hello!

    I wanted to share with you that I am getting this error “Warning: Undefined variable $default in /home/customer/www/smowl.net/public_html/wp-content/themes/child/rank-math.php on line 38”

    when I put this line of code:

    /**
    * Allow developer to default Snippet type by post type.
    *
    * @param string $type Snippet Type.
    * @param string $post_type Post type name.
    *
    */
    add_filter( ‘rank_math/settings/snippet/type’, function( $type, $post_type ) {
    return $default;
    }, 10, 2 );

    is it possible to know why this is happening? Thank you

    PD: I have disabled it in the meantime

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

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    The error is pretty self-explanatory. You are returning the variable $default without assigning it to anything first and as such it’s still undefined when you try to return it.

    Please note that all the code snippets we provide require further editing before they are added to the website and are intended to help developers change default behavior of the plugin.

    ​​​​​​​Don’t hesitate to get in touch if you have any other questions.

    Ok I understand thank you so much.

    Hello,

    Glad that helped.

    Please feel free to reach out to us again in case you need any other assistance.

    We are here to help.

    Thank you.

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

The ticket ‘error with code’ is closed to new replies.