Error 500
-
[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 73Looking at the error and the code, the issue is on line 73 where the
array_filtercallback is trying to access the$schemaparameter 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
You must be logged in to reply to this topic.