• Resolved Vu Tru So

    (@vutruso)


    [29-Dec-2025 02:09:53 UTC] PHP Fatal error:  Uncaught TypeError: Cannot access offset of type string on string in /home/kosmos/public_html/wp-content/plugins/seo-by-rank-math/includes/modules/schema/class-frontend.php:73
    Stack trace:
    #0 [internal function]: RankMath\Schema\Frontend->RankMath\Schema\{closure}()
    #1 /home/kosmos/public_html/wp-content/plugins/seo-by-rank-math/includes/modules/schema/class-frontend.php(74): array_filter()
    #2 /home/kosmos/public_html/wp-includes/class-wp-hook.php(341): RankMath\Schema\Frontend->add_schema()
    #3 /home/kosmos/public_html/wp-includes/plugin.php(256): WP_Hook->apply_filters()
    #4 /home/kosmos/public_html/wp-content/plugins/seo-by-rank-math/includes/traits/class-hooker.php(106): apply_filters_ref_array()
    #5 /home/kosmos/public_html/wp-content/plugins/seo-by-rank-math/includes/modules/schema/class-jsonld.php(149): RankMath\Schema\JsonLD->do_filter()
    #6 /home/kosmos/public_html/wp-includes/class-wp-hook.php(341): RankMath\Schema\JsonLD->json_ld()
    #7 /home/kosmos/public_html/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters()
    #8 /home/kosmos/public_html/wp-includes/plugin.php(570): WP_Hook->do_action()
    #9 /home/kosmos/public_html/wp-content/plugins/seo-by-rank-math/includes/traits/class-hooker.php(90): do_action_ref_array()
    #10 /home/kosmos/public_html/wp-content/plugins/seo-by-rank-math/includes/frontend/class-head.php(189): RankMath\Frontend\Head->do_action()
    #11 /home/kosmos/public_html/wp-includes/class-wp-hook.php(341): RankMath\Frontend\Head->head()
    #12 /home/kosmos/public_html/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters()
    #13 /home/kosmos/public_html/wp-includes/plugin.php(522): WP_Hook->do_action()
    #14 /home/kosmos/public_html/wp-includes/general-template.php(3197): do_action()
    #15 /home/kosmos/public_html/wp-content/themes/thuythu/header.php(18): wp_head()
    #16 /home/kosmos/public_html/wp-includes/template.php(814): require_once('/home/kosmos/pu...')
    #17 /home/kosmos/public_html/wp-includes/template.php(749): load_template()
    #18 /home/kosmos/public_html/wp-includes/general-template.php(48): locate_template()
    #19 /home/kosmos/public_html/wp-content/themes/thuythu/single-san-pham.php(3): get_header()
    #20 /home/kosmos/public_html/wp-includes/template-loader.php(125): include('/home/kosmos/pu...')
    #21 /home/kosmos/public_html/wp-blog-header.php(19): require_once('/home/kosmos/pu...')
    #22 /home/kosmos/public_html/index.php(17): require('/home/kosmos/pu...')
    #23 {main}
      thrown in /home/kosmos/public_html/wp-content/plugins/seo-by-rank-math/includes/modules/schema/class-frontend.php on line 73

    Looking at the error and the code, the issue is on line 73 where the array_filter callback is trying to access the $schema parameter as an array, but it’s receiving a string instead.

    The problem is here:

    $schemas = array_filter(
    DB::get_schemas( $post->ID ),
    function ( $schema ) {
    return ! in_array( $schema[‘@type’], [ ‘WooCommerceProduct’, ‘EDDProduct’ ], true );
    }
    );

    The DB::get_schemas() method is likely returning an array where some elements are strings instead of arrays. You need to add a type check before accessing array keys.

    the fix:

    $schemas = array_filter(
    DB::get_schemas( $post->ID ),
    function ( $schema ) {
    // Check if $schema is an array and has ‘@type’ key
    if ( ! is_array( $schema ) || ! isset( $schema[‘@type’] ) ) {
    return false;
    }
    return ! in_array( $schema[‘@type’], [ ‘WooCommerceProduct’, ‘EDDProduct’ ], true );
    }
    );

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Jeremy

    (@jeremrm)

    Hello there,

    Thank you for your query and we are so sorry about the trouble this must have caused.

    Yes, this fatal error usually occurs when Rank Math encounters a corrupted or invalid schema entry, where a schema value is stored as a string instead of an array. In most cases, this is related to a Product schema attached to a specific post or product.

    If this appears to be happening on a specific product page, please remove the existing Product schema in the Product list page (as shown in this screenshot): https://i.rankmath.com/i/iOjL4h

    Then, add a fresh Product schema again using the Schema Generator. Save/Update the page and check if the error is resolved.

      This usually fixes the issue by clearing out the corrupted schema data and regenerating it correctly.

      If the error still persists after doing this, please let us know here and we’ll assist you further.

      Looking forward to helping you with this one.

      Plugin Support Miguel

      (@miguelrm)

      Hello @vutruso,

      Since we didn’t hear back from you we are going to mark this ticket as resolved.

      Thank you.

      Thread Starter Vu Tru So

      (@vutruso)

      Thank you, I will try the photo you sent

      Plugin Support Jeremy

      (@jeremrm)

      Hello @vutruso,

      Sure, do let us know how that goes.

      In the meantime, don’t hesitate to get in touch with us if you have any other questions.

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

    You must be logged in to reply to this topic.