Illegal offset type in isset or empty in post_type_archive.php
-
We recently upgraded a client to PHP 8.1 and was receiving this error:
PHP Fatal error:? Uncaught TypeError: Illegal offset type in isset or empty in /[deleted]/wordpress/wp-content/plugins/query-wrangler/includes/overrides/post_type_archive.php:110After doing some debugging it appears that the $post_type being received was an array consisting of [ ‘podcast’, ‘post’ ].
Line 110 contains:
if ( isset( $post_type_archives[ $post_type ] ) && $qw_query = qw_get_query( (int) $post_type_archives[ $post_type ] ) ) {
Which throws the error.
Adding this fixes it:
if ( !is_array( $post_type ) && isset( $post_type_archives[ $post_type ] ) && $qw_query = qw_get_query( (int) $post_type_archives[ $post_type ] ) ) {
Is this the correct approach or did the original designer/developer for the site misuse the post_type tags and should be sending a string rather than array?
- The topic ‘Illegal offset type in isset or empty in post_type_archive.php’ is closed to new replies.